I hav开发者_如何学Pythone to create thumbnails with images uploaded by my users. The image formats can be PNG, JPG, GIF. I gave a try to java.awt and javax.imageio but it is hard to deal with all the cases (image too large, image too small, image in XXX format, image with transparency...). I would prefer a library simple and not so verbose.
What java library do you use to convert / edit / create images ?
you might like to explore JMagick
Well, we use ImageIO and Apache Sanselan, but JAI or - if you don't mind using native libaries - jmagick should do as well.
image too large, image too small, image in XXX format, image with transparency
I'm not sure there is a library that doesn't have constraints like that. Since the images might be PNG, JPG or GIF, the format problem shouldn't apply.
Transparency is format dependent and thus should not depend on the library.
I chose Scalr, not need for extra ImageMagick or JNI wrapper : http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/
On the other hand, quality is better with JMagick (if you can compile it and make it work)
Snowbound has the RasterMaster Java Imaging SDK. There is a decompress_bitmap call that will read in PNG, JPG, GIF and many other formats. The IMG_resize_bitmap_bicubic method can then be used to make a nice thumbnail.
You can go to Snowbound and push the "free trial" button to get a 30-day free trial version. The SDK comes with a Thumbnails code sample. If you want to learn more about the methods above before you expose your email address you can view the online documentation at RasterMaster.com.
Full disclosure - yes, I work for Snowbound.
精彩评论