[Wicket-user] images sizes

2006-04-25 Thread Alexander Lohse

Hi,

I know this is slightly off-topic, but I wonder if anyone ever solved  
this:
I have a gallery application that takes a directory and reads out all  
the images.(Actually I use two directories, one for thumbnails and  
one for the hires version).
I use PopupSettings to open a new window with the appropriate size  
for the hires image.
As I am coming from PHP I am used to a very quick function-call to  
find the size of an image. In Java I have to read the whole image  
into memory, which takes very long in terms of request-time.


I tried Jimi/ImageIO and even Swing-ImageIcon.

e.g.

BufferedImage image = null;
try {
image = ImageIO.read(new File(localHiresPath.toString 
()));

} catch (IOException exc) {

}

   if (image != null) {

ImageModel model = new ImageModel();
model.setHeight(image.getHeight());
model.setWidth(image.getWidth());

}


Is there any better/fast way to achive this? Maybe some nice wicket  
functionality?


Thank you for any help.

Alex




---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] images sizes

2006-04-25 Thread Timo Stamm

Alexander Lohse schrieb:
As I am coming from PHP I am used to a very quick function-call to find 
the size of an image. In Java I have to read the whole image into 
memory, which takes very long in terms of request-time.


You don't have to read the entire image. The dimensions are usually 
embedded in some meta-data section, so it is not necessary to decode the 
entire image just to get the dimensions.


This is how you get the dimensions from image files:

ImageInputStream i = ImageIO.createImageInputStream(new 
FileInputStream(file));

try {
   Iterator r = ImageIO.getImageReaders(i);
   if (r.hasNext()) {
  ImageReader reader = r.next();
  reader.setInput(i, true);
  width = reader.getWidth(0);
  height = reader.getHeight(0);
  formatName = reader.getFormatName().toLowerCase();
  reader.dispose();
   }
} finally {
   i.close();
}


HTH,
Timo


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] images sizes

2006-04-25 Thread Alexander Lohse

Hi Timo,

thank you very much. This was exactly what I needed! :-)

Alex


Alexander Lohse schrieb:
As I am coming from PHP I am used to a very quick function-call to  
find the size of an image. In Java I have to read the whole image  
into memory, which takes very long in terms of request-time.


You don't have to read the entire image. The dimensions are usually  
embedded in some meta-data section, so it is not necessary to  
decode the entire image just to get the dimensions.


This is how you get the dimensions from image files:

ImageInputStream i = ImageIO.createImageInputStream(new  
FileInputStream(file));

try {
   Iterator r = ImageIO.getImageReaders(i);
   if (r.hasNext()) {
  ImageReader reader = r.next();
  reader.setInput(i, true);
  width = reader.getWidth(0);
  height = reader.getHeight(0);
  formatName = reader.getFormatName().toLowerCase();
  reader.dispose();
   }
} finally {
   i.close();
}


HTH,
Timo





---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] images sizes

2006-04-26 Thread RĂ¼diger Schulz
Hello Alexander,

you might want to try Marco Schmidt's ImageInfo class, which not only
gets you the image dimensions, but other information like file format
etc., also without loading or rendering the whole image.

http://schmidt.devlib.org/image-info/index.html


-- 
greetings from Berlin,

RĂ¼diger Schulz


Alexander Lohse wrote on 25.04.2006 at 20:56:

> Hi,

> I know this is slightly off-topic, but I wonder if anyone ever solved
> this:
> I have a gallery application that takes a directory and reads out all
> the images.(Actually I use two directories, one for thumbnails and  
> one for the hires version).
> I use PopupSettings to open a new window with the appropriate size  
> for the hires image.
> As I am coming from PHP I am used to a very quick function-call to  
> find the size of an image. In Java I have to read the whole image  
> into memory, which takes very long in terms of request-time.

> I tried Jimi/ImageIO and even Swing-ImageIcon.

> e.g.

>  BufferedImage image = null;
>  try {
>  image = ImageIO.read(new File(localHiresPath.toString
> ()));
>  } catch (IOException exc) {

>  }

> if (image != null) {

>  ImageModel model = new ImageModel();
>  model.setHeight(image.getHeight());
>  model.setWidth(image.getWidth());
>   
>  }
>   

> Is there any better/fast way to achive this? Maybe some nice wicket
> functionality?

> Thank you for any help.

> Alex




> ---
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> ___
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user








---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user