The Dimension of an Image file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: The Dimension of an Image file

  1. #1
    Mohamed Abu Zur Guest

    The Dimension of an Image file


    How can I verify the dimension of an Jpeg or Gif file that I have in my server

    directory (e. g c:/Dir/image.jpeg) within a servlet.
    I want to verify the dimension before make the output.


    Thanks in advance

    Mohamed

  2. #2
    John Timney (MVP) Guest

    Re: The Dimension of an Image file

    Heres an example of resizing an image, pull out the bits that you
    need....notice the getWidth, getHeight methods.

    public void yoImage() {
    MediaTracker media = new MediaTracker(this);
    source = getImage(getDocumentBase(),"image.gif");
    media.addImage(source,0);
    try {
    media.waitForID(0);
    // scale down, half the original size
    ImageFilter replicate =
    new ReplicateScaleFilter
    (source.getWidth(this)/2, source.getHeight(this)/2);
    ImageProducer prod =
    new FilteredImageSource(source.getSource(),replicate);
    resizedImage = createImage(prod);
    media.addImage(resizedImage,1);
    media.waitForID(1);
    }
    catch(InterruptedException e) {}
    }




    --
    Regards

    John Timney
    Microsoft MVP
    (http://support.microsoft.com/support/mvp/program.asp)
    Co-Author Professional JSP
    ISBN: 1-861003-62-5



    Mohamed Abu Zur <mabuzur@medifusion.com> wrote in message
    news:39d21b7e$1@news.devx.com...

    How can I verify the dimension of an Jpeg or Gif file that I have in my
    server

    directory (e. g c:/Dir/image.jpeg) within a servlet.
    I want to verify the dimension before make the output.


    Thanks in advance

    Mohamed



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center