Changeset 4669
- Timestamp:
- 06/30/11 14:11:47 (2 years ago)
- Location:
- ImageMagick/trunk
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
coders/png.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ImageMagick/trunk/ChangeLog
r4663 r4669 1 2011-06-30 6.7.0-11 Glenn Randers-Pehrson <glennrp@image...> 2 * Added PNG:compression_level, compression_strategy, and compession_filter 3 defines to the PNG encoder. If these defines are used, they take 4 precedence over the -quality option. 5 1 6 2011-06-30 6.7.0-10 Cristy <quetzlzacatenango@image...> 2 7 * New version 6.7.0-10. -
ImageMagick/trunk/coders/png.c
r4659 r4669 860 860 write_png_colortype, 861 861 write_png_depth, 862 write_png_compression_level, 863 write_png_compression_strategy, 864 write_png_compression_filter, 862 865 write_png8, 863 866 write_png24, … … 9623 9626 9624 9627 8: Z_RLE strategy, all filters 9625 Unused prior to IM-6.7.0-10, was same as n69628 Unused prior to IM-6.7.0-10, was same as 6 9626 9629 9627 9630 9: Z_RLE strategy, no PNG filters 9628 Unused prior to IM-6.7.0-10, was same as n69631 Unused prior to IM-6.7.0-10, was same as 6 9629 9632 9630 9633 Note that using the -quality option, not all combinations of … … 9639 9642 image->quality; 9640 9643 9641 if (quality > 9) 9644 if (quality <= 9) 9645 { 9646 if (mng_info->write_png_compression_strategy == 0) 9647 mng_info->write_png_compression_strategy = Z_HUFFMAN_ONLY+1; 9648 } 9649 9650 else if (mng_info->write_png_compression_level == 0) 9642 9651 { 9643 9652 int … … 9646 9655 level=(int) MagickMin((ssize_t) quality/10,9); 9647 9656 9648 if (logging != MagickFalse) 9657 mng_info->write_png_compression_level = level+1; 9658 } 9659 9660 if (mng_info->write_png_compression_strategy == 0) 9661 { 9662 if ((quality %10) == 8 || (quality %10) == 9) 9663 mng_info->write_png_compression_strategy=Z_RLE; 9664 } 9665 9666 if (mng_info->write_png_compression_filter == 0) 9667 mng_info->write_png_compression_filter=((int) quality % 10) + 1; 9668 9669 if (logging != MagickFalse) 9670 { 9671 if (mng_info->write_png_compression_level) 9649 9672 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 9650 " Compression level: %d",level); 9651 9652 png_set_compression_level(ping,level); 9653 } 9654 9655 else 9656 { 9657 if (logging != MagickFalse) 9673 " Compression level: %d", 9674 (int) mng_info->write_png_compression_level-1); 9675 9676 if (mng_info->write_png_compression_strategy) 9658 9677 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 9659 " Compression strategy: Z_HUFFMAN_ONLY"); 9660 9661 png_set_compression_strategy(ping, Z_HUFFMAN_ONLY); 9662 } 9663 9664 if (logging != MagickFalse) 9665 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 9666 " Setting up filtering"); 9667 9668 if (mng_info->write_mng && ((quality % 10) == 7)) 9669 { 9670 #if defined(PNG_MNG_FEATURES_SUPPORTED) && defined(PNG_INTRAPIXEL_DIFFERENCING) 9671 if (logging != MagickFalse) 9672 { 9673 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 9674 " Filter_type: PNG_INTRAPIXEL_DIFFERENCING"); 9675 9676 /* This became available in libpng-1.0.9. Output must be a MNG. */ 9677 ping_filter_method=PNG_INTRAPIXEL_DIFFERENCING; 9678 } 9679 else 9680 #endif 9681 { 9682 if (logging != MagickFalse) 9683 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 9684 " Filter_type: 0"); 9685 ping_filter_method=0; 9686 } 9687 } 9688 9689 else 9690 { 9691 int 9692 base_filter; 9693 9694 if ((quality % 10) > 5) 9695 base_filter=PNG_ALL_FILTERS; 9696 9697 if ((quality %10) == 8) 9698 { 9699 png_set_compression_strategy(ping, Z_RLE); 9700 base_filter=PNG_NO_FILTERS; 9701 } 9702 9703 else if ((quality %10) == 9) 9704 { 9705 png_set_compression_strategy(ping, Z_RLE); 9706 } 9707 9708 else if ((quality % 10) < 5) 9709 base_filter=(int) quality % 10; 9710 9711 else if ((quality % 10) == 5) 9712 { 9713 if (((int) ping_color_type == PNG_COLOR_TYPE_GRAY) || 9714 ((int) ping_color_type == PNG_COLOR_TYPE_PALETTE) || 9715 (quality < 50)) 9716 base_filter=PNG_NO_FILTERS; 9717 9718 else 9719 base_filter=PNG_ALL_FILTERS; 9720 } 9721 9722 if (logging != MagickFalse) 9723 { 9724 if (base_filter == PNG_ALL_FILTERS) 9678 " Compression strategy: %d", 9679 (int) mng_info->write_png_compression_strategy-1); 9680 9681 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 9682 " Setting up filtering"); 9683 9684 if (mng_info->write_png_compression_filter == PNG_ALL_FILTERS+1) 9725 9685 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 9726 9686 " Base filter method: ADAPTIVE"); 9687 else if (mng_info->write_png_compression_filter == PNG_NO_FILTERS+1) 9688 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 9689 " Base filter method: NONE"); 9727 9690 else 9728 9691 (void) LogMagickEvent(CoderEvent,GetMagickModule(), 9729 " Base filter method: NONE"); 9692 " Base filter method: %d", 9693 (int) mng_info->write_png_compression_filter-1); 9694 } 9695 9696 if (mng_info->write_png_compression_level != 0) 9697 png_set_compression_level(ping,mng_info->write_png_compression_level-1); 9698 9699 if (mng_info->write_png_compression_filter == 6) 9700 { 9701 if (((int) ping_color_type == PNG_COLOR_TYPE_GRAY) || 9702 ((int) ping_color_type == PNG_COLOR_TYPE_PALETTE) || 9703 (quality < 50)) 9704 png_set_filter(ping,PNG_FILTER_TYPE_BASE,PNG_NO_FILTERS); 9705 else 9706 png_set_filter(ping,PNG_FILTER_TYPE_BASE,PNG_ALL_FILTERS); 9707 } 9708 9709 if (mng_info->write_png_compression_filter == 7 || 9710 mng_info->write_png_compression_filter == 10) 9711 png_set_filter(ping,PNG_FILTER_TYPE_BASE,PNG_ALL_FILTERS); 9712 9713 else if (mng_info->write_png_compression_filter == 8) 9714 { 9715 #if defined(PNG_MNG_FEATURES_SUPPORTED) && defined(PNG_INTRAPIXEL_DIFFERENCING) 9716 if (mng_info->write_mng) 9717 { 9718 if (((int) ping_color_type == PNG_COLOR_TYPE_RGB) || 9719 ((int) ping_color_type == PNG_COLOR_TYPE_RGBA)) 9720 ping_filter_method=PNG_INTRAPIXEL_DIFFERENCING; 9730 9721 } 9731 9732 png_set_filter(ping,PNG_FILTER_TYPE_BASE,base_filter); 9733 } 9722 #endif 9723 png_set_filter(ping,PNG_FILTER_TYPE_BASE,0); 9724 } 9725 9726 else if (mng_info->write_png_compression_filter == 9) 9727 png_set_filter(ping,PNG_FILTER_TYPE_BASE,PNG_NO_FILTERS); 9728 9729 else if (mng_info->write_png_compression_filter != 0) 9730 png_set_filter(ping,PNG_FILTER_TYPE_BASE, 9731 mng_info->write_png_compression_filter-1); 9732 9733 if (mng_info->write_png_compression_strategy != 0) 9734 png_set_compression_strategy(ping, 9735 mng_info->write_png_compression_strategy-1); 9736 9734 9737 9735 9738 if ((ping_exclude_tEXt == MagickFalse || ping_exclude_zTXt == MagickFalse) && … … 10984 10987 if (value != NULL) 10985 10988 mng_info->ping_preserve_colormap=MagickTrue; 10989 10990 /* Thes compression-level, compression-strategy, and compression-filter 10991 * defines take precedence over values from the -quality option. 10992 */ 10993 value=GetImageArtifact(image,"png:compression-level"); 10994 if (value == NULL) 10995 value=GetImageOption(image_info,"png:compression-level"); 10996 if (value != NULL) 10997 { 10998 /* To do: use a "LocaleInteger:()" function here. */ 10999 11000 /* We have to add 1 to everything because 0 is a valid input, 11001 * and we want to use 0 (the default) to mean undefined. 11002 */ 11003 if (LocaleCompare(value,"0") == 0) 11004 mng_info->write_png_compression_level = 1; 11005 11006 if (LocaleCompare(value,"1") == 0) 11007 mng_info->write_png_compression_level = 2; 11008 11009 else if (LocaleCompare(value,"2") == 0) 11010 mng_info->write_png_compression_level = 3; 11011 11012 else if (LocaleCompare(value,"3") == 0) 11013 mng_info->write_png_compression_level = 4; 11014 11015 else if (LocaleCompare(value,"4") == 0) 11016 mng_info->write_png_compression_level = 5; 11017 11018 else if (LocaleCompare(value,"5") == 0) 11019 mng_info->write_png_compression_level = 6; 11020 11021 else if (LocaleCompare(value,"6") == 0) 11022 mng_info->write_png_compression_level = 7; 11023 11024 else if (LocaleCompare(value,"7") == 0) 11025 mng_info->write_png_compression_level = 8; 11026 11027 else if (LocaleCompare(value,"8") == 0) 11028 mng_info->write_png_compression_level = 9; 11029 11030 else if (LocaleCompare(value,"9") == 0) 11031 mng_info->write_png_compression_level = 10; 11032 11033 else 11034 (void) ThrowMagickException(&image->exception, 11035 GetMagickModule(),CoderWarning, 11036 "ignoring invalid defined png:compression-level", 11037 "=%s",value); 11038 } 11039 11040 value=GetImageArtifact(image,"png:compression-strategy"); 11041 if (value == NULL) 11042 value=GetImageOption(image_info,"png:compression-strategy"); 11043 if (value != NULL) 11044 { 11045 11046 if (LocaleCompare(value,"0") == 0) 11047 mng_info->write_png_compression_strategy = Z_DEFAULT_STRATEGY+1; 11048 11049 else if (LocaleCompare(value,"1") == 0) 11050 mng_info->write_png_compression_strategy = Z_FILTERED+1; 11051 11052 else if (LocaleCompare(value,"2") == 0) 11053 mng_info->write_png_compression_strategy = Z_HUFFMAN_ONLY+1; 11054 11055 else if (LocaleCompare(value,"3") == 0) 11056 mng_info->write_png_compression_strategy = Z_RLE+1; 11057 11058 else if (LocaleCompare(value,"4") == 0) 11059 mng_info->write_png_compression_strategy = Z_FIXED+1; 11060 11061 else 11062 (void) ThrowMagickException(&image->exception, 11063 GetMagickModule(),CoderWarning, 11064 "ignoring invalid defined png:compression-strategy", 11065 "=%s",value); 11066 } 11067 11068 value=GetImageArtifact(image,"png:compression-filter"); 11069 if (value == NULL) 11070 value=GetImageOption(image_info,"png:compression-filter"); 11071 if (value != NULL) 11072 { 11073 11074 /* To do: combinations of filters allowed by libpng 11075 * masks 0x08 through 0xf8 11076 * 11077 * Implement this as a comma-separated list of 0,1,2,3,4,5 11078 * where 5 is a special case meaning PNG_ALL_FILTERS. 11079 */ 11080 11081 if (LocaleCompare(value,"0") == 0) 11082 mng_info->write_png_compression_filter = 1; 11083 11084 if (LocaleCompare(value,"1") == 0) 11085 mng_info->write_png_compression_filter = 2; 11086 11087 else if (LocaleCompare(value,"2") == 0) 11088 mng_info->write_png_compression_filter = 3; 11089 11090 else if (LocaleCompare(value,"3") == 0) 11091 mng_info->write_png_compression_filter = 4; 11092 11093 else if (LocaleCompare(value,"4") == 0) 11094 mng_info->write_png_compression_filter = 5; 11095 11096 else if (LocaleCompare(value,"5") == 0) 11097 mng_info->write_png_compression_filter = 6; 11098 11099 11100 else 11101 (void) ThrowMagickException(&image->exception, 11102 GetMagickModule(),CoderWarning, 11103 "ignoring invalid defined png:compression-filter", 11104 "=%s",value); 11105 } 10986 11106 10987 11107 excluding=MagickFalse;
Note: See TracChangeset
for help on using the changeset viewer.
