Page 1 of 2

PNG size become bigger when after thumbnail the png

Posted: 2015-03-05T00:02:30-07:00
by needkane
Hi:
Recently ,more and more png image size become bigger when after thumbnail.
Image:http://s3-us-west-2.amazonaws.com/qiniu-bs/bigger.png ( 720x300,57kb)

http://s3-us-west-2.amazonaws.com/qiniu-bs/bigger2.png (681x337,97.1kb)


Command:
convert bigger.png -thumbnail 600x +repage result.png

We find the result.png width and height both less than original, but the image's size both bigger than original.

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-05T01:07:15-07:00
by snibgo
What version of IM are you using?

With v6.9.0-0 I get:

Code: Select all

f:\web\im>%IM%identify bigger.png
bigger.png PNG 720x300 720x300+0+0 8-bit sRGB 256c 56.5KB 0.000u 0:00.000

f:\web\im>%IM%convert bigger.png -thumbnail 600x b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 124KB 0.000u 0:00.000
The width has shrunk to 600 pixels, as required. The size has more than doubled. We can see why: the "256c" label has gone. The input had only 256 colours, but interpolated resizing has increased the number of colours, so the output isn't palleted. I can cure this:

Code: Select all

f:\web\im>%IM%convert bigger.png -thumbnail 600x -colors 255 -type Palette b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 253c 53.1KB 0.000u 0:00.000

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-05T02:53:19-07:00
by needkane
snibgo wrote:What version of IM are you using?

With v6.9.0-0 I get:

Code: Select all

f:\web\im>%IM%identify bigger.png
bigger.png PNG 720x300 720x300+0+0 8-bit sRGB 256c 56.5KB 0.000u 0:00.000

f:\web\im>%IM%convert bigger.png -thumbnail 600x b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 124KB 0.000u 0:00.000
The width has shrunk to 600 pixels, as required. The size has more than doubled. We can see why: the "256c" label has gone. The input had only 256 colours, but interpolated resizing has increased the number of colours, so the output isn't palleted. I can cure this:

Code: Select all

f:\web\im>%IM%convert bigger.png -thumbnail 600x -colors 255 -type Palette b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 253c 53.1KB 0.000u 0:00.000

Thank you very much ,can you tell me how to optimise imagemagick to reduce computer memory consumption

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-05T03:13:00-07:00
by snibgo
See http://www.imagemagick.org/script/architecture.php

Q8 uses half the memory of Q16.

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-05T03:30:30-07:00
by needkane
snibgo wrote:See http://www.imagemagick.org/script/architecture.php

Q8 uses half the memory of Q16.

Thank you very much,can you help me this issue viewtopic.php?f=3&t=27148

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-06T00:56:27-07:00
by needkane
needkane wrote:
snibgo wrote:See http://www.imagemagick.org/script/architecture.php

Q8 uses half the memory of Q16.

Thank you very much,can you help me this issue viewtopic.php?f=3&t=27148

Sir,another quesstion :webp image become bigger too after thumbnail
Image:http://7te8ta.com1.z0.glb.clouddn.com/p ... pload.webp

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-06T03:52:22-07:00
by snibgo
You can use "-quality" with webp to trade-off quality against size. For example:

Code: Select all

f:\web\im>%IM%convert upload.webp -thumbnail 200x -quality 10 x.webp
upload.webp is 5400 bytes. x.webp is 2034 bytes.

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-09T02:34:09-07:00
by needkane
snibgo wrote:You can use "-quality" with webp to trade-off quality against size. For example:

Code: Select all

f:\web\im>%IM%convert upload.webp -thumbnail 200x -quality 10 x.webp
upload.webp is 5400 bytes. x.webp is 2034 bytes.


Sir, the same question like bmp
Image:http://s3-us-west-2.amazonaws.com/qiniu-bs/bigger.png ( 720x300,57kb)
Command:
convert bigger.png -thumbnail 719x +repage result.png

We find the result.png width and height both less than original, but the image's size both bigger than original.

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-09T02:37:09-07:00
by snibgo
Pngcrush may be useful.

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-09T03:05:08-07:00
by needkane
snibgo wrote:Pngcrush may be useful.
Your means is imagemagick can't resolve?

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-09T03:16:22-07:00
by snibgo
As upthread: "The "256c" label has gone. The input had only 256 colours, but interpolated resizing has increased the number of colours, so the output isn't palleted." So use "-colors 255 -type Palette" again.

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-09T10:55:47-07:00
by glennrp
snibgo wrote:Pngcrush may be useful.
Pngcrush won't help much if there are more than 256 colors (including the background color) present.

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-10T20:54:31-07:00
by needkane
glennrp wrote:
snibgo wrote:Pngcrush may be useful.
Pngcrush won't help much if there are more than 256 colors (including the background color) present.
pngquant is a good tool,but I want use imagemagick

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-10T21:01:00-07:00
by needkane
snibgo wrote:As upthread: "The "256c" label has gone. The input had only 256 colours, but interpolated resizing has increased the number of colours, so the output isn't palleted." So use "-colors 255 -type Palette" again.
Do you know the rules
viewtopic.php?f=3&t=27130

Re: PNG size become bigger when after thumbnail the png

Posted: 2015-03-15T21:26:59-07:00
by needkane
snibgo wrote:What version of IM are you using?

With v6.9.0-0 I get:

Code: Select all

f:\web\im>%IM%identify bigger.png
bigger.png PNG 720x300 720x300+0+0 8-bit sRGB 256c 56.5KB 0.000u 0:00.000

f:\web\im>%IM%convert bigger.png -thumbnail 600x b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 124KB 0.000u 0:00.000
The width has shrunk to 600 pixels, as required. The size has more than doubled. We can see why: the "256c" label has gone. The input had only 256 colours, but interpolated resizing has increased the number of colours, so the output isn't palleted. I can cure this:

Code: Select all

f:\web\im>%IM%convert bigger.png -thumbnail 600x -colors 255 -type Palette b.png

f:\web\im>%IM%identify b.png
b.png PNG 600x250 600x250+0+0 8-bit sRGB 253c 53.1KB 0.000u 0:00.000

Image :http://s3-us-west-2.amazonaws.com/qiniu-bs/2.png
Type :Palette2

If use command:
convert 2.png -thumbnail 400x b.png //size bigger than origin

But use command like you :
convert 2.png -thumbnail 400x -colors 2 -type Palette b.png
or
convert 2.png -thumbnail 400x -colors 1 -type Palette b.png

The result only one color and Opaque