• 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

PNG Resize

 
Greenhorn
Posts: 5
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I'm trying to Resize a PNG image using Jmagick.

Dimensions of the Source Image:

Dimensions: 1024 * 1024
Bit depth : 8
Size : 311 KB

Generated Image , even though the dimension is less, file size is more.

Dimensions: 395 * 640
Bit depth : 32
Size : 568 KB

I see that BitDepth is also getting increased.




Versions=
ImageMagick 6.8.9-9
Jmagick 6.7.7

What is the mistake i'm doing here?

Thanks in Advance

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But the bit depth of the original image is 8, and of the converted image is 32. That means for every pixel there are now 32 bits instead of 8 bits, which would explain why the file size is a lot larger.

Is the original image a grayscale image? The converted image seems to be an RGB image.

Maybe you should do this:
 
Santhana Arunkumar
Greenhorn
Posts: 5
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Jong,

The Image is Colored only.

quantizeInfo.setColorspace(ColorspaceType.GRAYColorspace);

This changes the output image to Grayscale, which is not acceptable. I want a colored image with reduced size.

I am Attaching the Original and re-sized image's Verbose output of the identify cmd.

Original Image




Resized Image


 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your source image is of type "PaletteAlpha", and your result image is of type "TrueColorAlpha". That's why the source image has 8 bits per pixel and the result image has 32 bits per pixel.

You have to set the parameters in such a way that you get a palette image as the output, instead of a true color image. I don't know enough about ImageMagick and JMagick to tell you exactly how to do that.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic