ping_file_depth = ping_bit_depth;
+ /* Save bit-depth and color-type in case we later want to write a PNG00 */
+ {
+ char
+ msg[MaxTextExtent];
+
+ (void) FormatLocaleString(msg,MaxTextExtent,"%d",(int) ping_color_type);
+ (void) SetImageProperty(image,"png:IHDR.color-type-orig ",msg,exception);
+
+ (void) FormatLocaleString(msg,MaxTextExtent,"%d",(int) ping_bit_depth);
+ (void) SetImageProperty(image,"png:IHDR.bit-depth-orig ",msg,exception);
+ }
+
(void) png_get_tRNS(ping, ping_info, &ping_trans_alpha, &ping_num_trans,
&ping_trans_color);
(png_get_valid(ping,ping_info,PNG_INFO_tRNS))) ?
BlendPixelTrait : UndefinedPixelTrait;
+ if (image->alpha_trait == BlendPixelTrait)
+ {
+ if (ping_color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ (void) SetImageType(image,GrayscaleMatteType,exception);
+
+ else if (ping_color_type == PNG_COLOR_TYPE_PALETTE)
+ (void) SetImageType(image,PaletteMatteType,exception);
+
+ else
+ (void) SetImageType(image,TrueColorMatteType,exception);
+ }
+
+ else
+ {
+ if (ping_color_type == PNG_COLOR_TYPE_GRAY)
+ (void) SetImageType(image,GrayscaleType,exception);
+
+ else if (ping_color_type == PNG_COLOR_TYPE_PALETTE)
+ (void) SetImageType(image,PaletteType,exception);
+
+ else
+ (void) SetImageType(image,TrueColorType,exception);
+ }
+
/* Set more properties for identify to retrieve */
{
char
((image->gamma < .45) || (image->gamma > .46)))
SetImageColorspace(image,RGBColorspace,exception);
- if ((LocaleCompare(image_info->magick,"PNG24") == 0) ||
- (LocaleCompare(image_info->magick,"PNG48") == 0))
- {
- (void) SetImageType(image,TrueColorType,exception);
- image->alpha_trait=UndefinedPixelTrait;
- }
-
- if ((LocaleCompare(image_info->magick,"PNG32") == 0) ||
- (LocaleCompare(image_info->magick,"PNG64") == 0))
- (void) SetImageType(image,TrueColorMatteType,exception);
-
if (logging != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" page.w: %.20g, page.h: %.20g,page.x: %.20g, page.y: %.20g.",
entry->module=ConstantString("PNG");
(void) RegisterMagickInfo(entry);
+ entry=SetMagickInfo("PNG00");
+
+#if defined(MAGICKCORE_PNG_DELEGATE)
+ entry->decoder=(DecodeImageHandler *) ReadPNGImage;
+ entry->encoder=(EncodeImageHandler *) WritePNGImage;
+#endif
+
+ entry->magick=(IsImageFormatHandler *) IsPNG;
+ entry->adjoin=MagickFalse;
+ entry->description=ConstantString("PNG inheriting subformat from original");
+ entry->module=ConstantString("PNG");
+ (void) RegisterMagickInfo(entry);
+
entry=SetMagickInfo("JNG");
#if defined(JNG_SUPPORTED)
(void) UnregisterMagickInfo("PNG32");
(void) UnregisterMagickInfo("PNG48");
(void) UnregisterMagickInfo("PNG64");
+ (void) UnregisterMagickInfo("PNG00");
(void) UnregisterMagickInfo("JNG");
#ifdef PNG_SETJMP_NOT_THREAD_SAFE
% each pixel can have any value from 0 to 65535. The alpha
% channel is present even if the image is fully opaque.
%
+% o PNG00: A PNG that inherits its colortype and bit-depth from the input
+% image, if the input was a PNG, is written. If these values
+% cannot be found, then "PNG00" falls back to the regular "PNG"
+% format.
+%
% o -define: For more precise control of the PNG output, you can use the
% Image options "png:bit-depth" and "png:color-type". These
% can be set from the commandline with "-define" and also
else if (LocaleCompare(value,"png64") == 0)
mng_info->write_png64 = MagickTrue;
}
+
+ if (LocaleCompare(value,"png00") == 0)
+ {
+ /* Retrieve png:IHDR.bit-depth-orig and png:IHDR.color-type-orig
+ Note that whitespace at the end of the property names must match
+ that in the corresponding SetImageProperty() calls.
+ */
+ (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+ " Format=%s",value);
+
+ value=GetImageProperty(image,"png:IHDR.bit-depth-orig ",exception);
+
+ (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+ " png00 inherited bit depth=%s",value);
+
+ if (value != (char *) NULL)
+ {
+ if (LocaleCompare(value,"1") == 0)
+ mng_info->write_png_depth = 1;
+
+ else if (LocaleCompare(value,"1") == 0)
+ mng_info->write_png_depth = 2;
+
+ else if (LocaleCompare(value,"2") == 0)
+ mng_info->write_png_depth = 4;
+
+ else if (LocaleCompare(value,"8") == 0)
+ mng_info->write_png_depth = 8;
+
+ else if (LocaleCompare(value,"16") == 0)
+ mng_info->write_png_depth = 16;
+ }
+
+ value=GetImageProperty(image,"png:IHDR.color-type-orig ",exception);
+
+ (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+ " png00 inherited color type=%s",value);
+
+ if (value != (char *) NULL)
+ {
+ if (LocaleCompare(value,"0") == 0)
+ mng_info->write_png_colortype = 1;
+
+ else if (LocaleCompare(value,"2") == 0)
+ mng_info->write_png_colortype = 3;
+
+ else if (LocaleCompare(value,"3") == 0)
+ mng_info->write_png_colortype = 4;
+
+ else if (LocaleCompare(value,"4") == 0)
+ mng_info->write_png_colortype = 5;
+
+ else if (LocaleCompare(value,"6") == 0)
+ mng_info->write_png_colortype = 7;
+ }
+ }
+
if (mng_info->write_png8)
{
mng_info->write_png_colortype = /* 3 */ 4;