• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Urgent: Need to know the size of Image Uploaded

 
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
I have an application where i upload a image through a web page to the server and put it in the database, i need to check that the image is of particualr height and width only and then only insert in the DB else show error. I tried it by converting the bytes as below but got -1 as height and width.
This coding is in the servlet class:
// f is the file object uploaded.
byte [] b=new byte[(int)f.length()];
fis.read(b);
System.out.println("after file read");
// this is the code to check the file length
Toolkit toolKit=Toolkit.getDefaultToolkit();
Image image=toolKit.createImage(b);
int width=image.getWidth(null);
int heigth=image.getHeight(null);
System.out.println("Height is "+heigth+" Width is "+width);
***************
I get both as -1
I will be very thankful if anyone can help me out in this.
Regards,
Daman

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic