DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links