[cl-gd-devel] PNG compression
I was experimenting with write-png-to-stream trying :compression-level from -1 to 9 but it doesn't change the size of the image. For jpeg quality level works though. What can I check for PNG compression to work? Thank you, Andrew
2008/10/1 Andrei Stebakov <lispercat@gmail.com>:
I was experimenting with write-png-to-stream trying :compression-level from -1 to 9 but it doesn't change the size of the image. For jpeg quality level works though. What can I check for PNG compression to work?
Are you sure that libgd supports compressing PNGs? If so, it may be a fixable API problem. Please verify that libgd itself supports compression, then let us know. Thanks, Hans
On the site http://www.libgd.org/GdHistory they say: That "the PNG compression level can now be specified when writing PNG images. See the new gdImagePngEx, gdImagePngEx, gdImagePngCtxEx, and gdImagePngPtrEx functions.". This feature starts from version 2.0.12. I have 2.0.35, so yes, libgd should support it. Thank you, Andrew On Wed, Oct 1, 2008 at 6:53 PM, Hans Hübner <hans@huebner.org> wrote:
2008/10/1 Andrei Stebakov <lispercat@gmail.com>:
I was experimenting with write-png-to-stream trying :compression-level from -1 to 9 but it doesn't change the size of the image. For jpeg quality level works though. What can I check for PNG compression to work?
Are you sure that libgd supports compressing PNGs? If so, it may be a fixable API problem. Please verify that libgd itself supports compression, then let us know.
Thanks, Hans _______________________________________________ cl-gd-devel site list cl-gd-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-gd-devel
Works for me: GD-TEST> (with-open-file (f "/tmp/test.png") (file-length f)) 3005915 GD-TEST> (with-image* (1000 1000 t) (write-image-to-file "/tmp/test.png" :compression-level 1 :if-exists :supersede)) #S(CL-GD::IMAGE :IMG #<A Foreign Pointer #x58E000>) GD-TEST> (with-open-file (f "/tmp/test.png") (file-length f)) 13178 GD-TEST> (with-image* (1000 1000 t) (write-image-to-file "/tmp/test.png" :compression-level 9 :if-exists :supersede)) #S(CL-GD::IMAGE :IMG #<A Foreign Pointer #x58E000>) GD-TEST> (with-open-file (f "/tmp/test.png") (file-length f)) 2987 FreeBSD, cl-gd 0.5.6, gd-2.0.35 What are your results for this test? -Hans 2008/10/1 Andrei Stebakov <lispercat@gmail.com>:
On the site http://www.libgd.org/GdHistory they say: That "the PNG compression level can now be specified when writing PNG images. See the new gdImagePngEx, gdImagePngEx, gdImagePngCtxEx, and gdImagePngPtrEx functions.". This feature starts from version 2.0.12. I have 2.0.35, so yes, libgd should support it.
Thank you, Andrew
On Wed, Oct 1, 2008 at 6:53 PM, Hans Hübner <hans@huebner.org> wrote:
2008/10/1 Andrei Stebakov <lispercat@gmail.com>:
I was experimenting with write-png-to-stream trying :compression-level from -1 to 9 but it doesn't change the size of the image. For jpeg quality level works though. What can I check for PNG compression to work?
Are you sure that libgd supports compressing PNGs? If so, it may be a fixable API problem. Please verify that libgd itself supports compression, then let us know.
Thanks, Hans _______________________________________________ cl-gd-devel site list cl-gd-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-gd-devel
_______________________________________________ cl-gd-devel site list cl-gd-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-gd-devel
Yes, it works. The scenario that I have is like this: I am trying to down-size a png image so I 1. open it with with-image-from-file 2. copy resized image (copy-image old-image new-image ....) 3. save it (write-image-to-file new-image-file-name :image new-image :compression-level 5) In my case :compression-level doesn't change the size of the output image. Probably it happens because the original file that I am trying to re-size is already compressed to the maximum. Thank you, Andrew On Wed, Oct 1, 2008 at 7:25 PM, Hans Hübner <hans@huebner.org> wrote:
On Wed, Oct 1, 2008 at 19:24, Hans Hübner <hans@huebner.org> wrote:
Works for me:
Obviously, I made a copy and paste error. This:
GD-TEST> (with-open-file (f "/tmp/test.png") (file-length f)) 3005915
is for :compression-level 0, obviously.
-Hans _______________________________________________ cl-gd-devel site list cl-gd-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-gd-devel
2008/10/2 Andrei Stebakov <lispercat@gmail.com>:
Yes, it works. The scenario that I have is like this: I am trying to down-size a png image so I
open it with with-image-from-file copy resized image (copy-image old-image new-image ....) save it (write-image-to-file new-image-file-name :image new-image :compression-level 5)
In my case :compression-level doesn't change the size of the output image. Probably it happens because the original file that I am trying to re-size is already compressed to the maximum.
I fear I don't know enough about PNG compression to say anything profound here. I do suspect that it is a general GD issue rather than a cl-gd problem, so maybe asking on some GD support channel would be helpful? You'd propably need to supply the image in question to have someone comment on what compression you can expect. -Hans
Thank you, Hans. Looks like I need to contact libgd folks to learn more about this type of operation. Andrew On Thu, Oct 2, 2008 at 11:28 AM, Hans Hübner <hans@huebner.org> wrote:
2008/10/2 Andrei Stebakov <lispercat@gmail.com>:
Yes, it works. The scenario that I have is like this: I am trying to down-size a png image so I
open it with with-image-from-file copy resized image (copy-image old-image new-image ....) save it (write-image-to-file new-image-file-name :image new-image :compression-level 5)
In my case :compression-level doesn't change the size of the output image. Probably it happens because the original file that I am trying to re-size is already compressed to the maximum.
I fear I don't know enough about PNG compression to say anything profound here. I do suspect that it is a general GD issue rather than a cl-gd problem, so maybe asking on some GD support channel would be helpful? You'd propably need to supply the image in question to have someone comment on what compression you can expect.
-Hans _______________________________________________ cl-gd-devel site list cl-gd-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-gd-devel
participants (2)
-
Andrei Stebakov -
Hans Hübner