X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=PerlMagick%2FMagick.xs;h=a5a889a95ec9b003da9fd86b6c4ca91c9f3ea683;hb=0f5df816b3e2ca1dd4dec9c01539739a2df73e98;hp=159845aa40c07ec911639d5d2aec7ad3ade421ae;hpb=d845f8bf9311ae48753932aba552cf01843a3b76;p=imagemagick diff --git a/PerlMagick/Magick.xs b/PerlMagick/Magick.xs index 159845aa4..a5a889a95 100644 --- a/PerlMagick/Magick.xs +++ b/PerlMagick/Magick.xs @@ -23,7 +23,7 @@ % February 1997 % % % % % -% Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization % +% Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization % % dedicated to making software imaging solutions freely available. % % % % You may not use this file except in compliance with the License. You may % @@ -531,8 +531,6 @@ static struct { "Morphology", { {"kernel", StringReference}, {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions}, {"iterations", IntegerReference} } }, - { "Sans", { {"matrix", ArrayReference} } }, - { "Color", { {"color", StringReference} } }, { "Mode", { {"geometry", StringReference}, {"width", IntegerReference},{"height", IntegerReference}, {"channel", MagickChannelOptions} } }, @@ -561,6 +559,12 @@ static struct {"x", IntegerReference}, {"y", IntegerReference}, {"gravity", MagickGravityOptions}, {"offset", StringReference}, {"dx", IntegerReference}, {"dy", IntegerReference} } }, + { "Color", { {"color", StringReference} } }, + { "WaveletDenoise", { {"geometry", StringReference}, + {"threshold", RealReference}, {"softness", RealReference}, + {"channel", MagickChannelOptions} } }, + { "Colorspace", { {"colorspace", MagickColorspaceOptions} } }, + { "AutoThreshold", { {"method", MagickAutoThresholdOptions} } }, }; static SplayTreeInfo @@ -1180,7 +1184,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'B': @@ -1222,7 +1229,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'C': @@ -1245,7 +1255,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (SvPOK(sval)) clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception); for ( ; image; image=image->next) - SetImageMask(image,clip_mask,exception); + SetImageMask(image,ReadPixelMask,clip_mask,exception); break; } if (LocaleNCompare(attribute,"colormap",8) == 0) @@ -1297,8 +1307,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, break; } for ( ; image; image=image->next) - (void) TransformImageColorspace(image,(ColorspaceType) sp, - exception); + (void) SetImageColorspace(image,(ColorspaceType) sp,exception); break; } if (LocaleCompare(attribute,"comment") == 0) @@ -1328,7 +1337,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'D': @@ -1431,7 +1443,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'E': @@ -1464,7 +1479,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'F': @@ -1534,7 +1552,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'G': @@ -1578,7 +1599,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'I': @@ -1645,7 +1669,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'L': @@ -1664,7 +1691,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'M': @@ -1673,10 +1703,11 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (LocaleCompare(attribute,"magick") == 0) { if (info) - (void) FormatLocaleString(info->image_info->filename,MagickPathExtent, - "%s:",SvPV(sval,na)); + (void) FormatLocaleString(info->image_info->filename, + MagickPathExtent,"%s:",SvPV(sval,na)); for ( ; image; image=image->next) - (void) CopyMagickString(image->magick,SvPV(sval,na),MagickPathExtent); + (void) CopyMagickString(image->magick,SvPV(sval,na), + MagickPathExtent); break; } if (LocaleCompare(attribute,"map-limit") == 0) @@ -1700,7 +1731,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (SvPOK(sval)) mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception); for ( ; image; image=image->next) - SetImageMask(image,mask,exception); + SetImageMask(image,ReadPixelMask,mask,exception); break; } if (LocaleCompare(attribute,"mattecolor") == 0) @@ -1708,9 +1739,9 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color, exception); if (info) - info->image_info->matte_color=target_color; + info->image_info->alpha_color=target_color; for ( ; image; image=image->next) - image->matte_color=target_color; + image->alpha_color=target_color; break; } if (LocaleCompare(attribute,"matte") == 0) @@ -1758,7 +1789,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'O': @@ -1789,7 +1823,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'P': @@ -1873,24 +1910,13 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, } break; } - if (LocaleCompare(attribute,"preview") == 0) - { - sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse, - SvPV(sval,na)) : SvIV(sval); - if (sp < 0) - { - ThrowPerlException(exception,OptionError,"UnrecognizedType", - SvPV(sval,na)); - break; - } - if (info) - info->image_info->preview_type=(PreviewType) sp; - break; - } if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'Q': @@ -1907,12 +1933,27 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'R': case 'r': { + if (LocaleCompare(attribute,"read-mask") == 0) + { + Image + *mask; + + mask=(Image *) NULL; + if (SvPOK(sval)) + mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception); + for ( ; image; image=image->next) + SetImageMask(image,ReadPixelMask,mask,exception); + break; + } if (LocaleCompare(attribute,"red-primary") == 0) { for ( ; image; image=image->next) @@ -1983,7 +2024,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'S': @@ -2033,7 +2077,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'T': @@ -2112,7 +2159,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'U': @@ -2166,7 +2216,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'V': @@ -2186,12 +2239,6 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse; break; } - if (LocaleCompare(attribute,"view") == 0) - { - if (info) - (void) CloneString(&info->image_info->view,SvPV(sval,na)); - break; - } if (LocaleCompare(attribute,"virtual-pixel") == 0) { sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions, @@ -2209,7 +2256,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } case 'W': @@ -2228,10 +2278,25 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, } break; } + if (LocaleCompare(attribute,"write-mask") == 0) + { + Image + *mask; + + mask=(Image *) NULL; + if (SvPOK(sval)) + mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception); + for ( ; image; image=image->next) + SetImageMask(image,WritePixelMask,mask,exception); + break; + } if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } default: @@ -2239,7 +2304,10 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image, if (info) SetImageOption(info->image_info,attribute,SvPV(sval,na)); for ( ; image; image=image->next) - SetImageProperty(image,attribute,SvPV(sval,na),exception); + { + (void) SetImageProperty(image,attribute,SvPV(sval,na),exception); + (void) SetImageArtifact(image,attribute,SvPV(sval,na)); + } break; } } @@ -4069,46 +4137,46 @@ Features(ref,...) { #define ChannelFeatures(channel,direction) \ { \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].angular_second_moment[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].contrast[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].contrast[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].variance_sum_of_squares[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].inverse_difference_moment[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].sum_average[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].sum_variance[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].sum_entropy[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].entropy[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].difference_variance[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].difference_entropy[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].measure_of_correlation_1[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].measure_of_correlation_2[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_features[channel].maximum_correlation_coefficient[direction]); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ } @@ -4195,20 +4263,24 @@ Features(ref,...) count=0; for ( ; image; image=image->next) { + register ssize_t + j; + channel_features=GetImageFeatures(image,distance,exception); if (channel_features == (ChannelFeatures *) NULL) continue; count++; - EXTEND(sp,280*count); - for (i=0; i < 4; i++) + for (j=0; j < 4; j++) { - ChannelFeatures(RedChannel,i); - ChannelFeatures(GreenChannel,i); - ChannelFeatures(BlueChannel,i); - if (image->colorspace == CMYKColorspace) - ChannelFeatures(BlackChannel,i); - if (image->alpha_trait != UndefinedPixelTrait) - ChannelFeatures(AlphaChannel,i); + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel channel=GetPixelChannelChannel(image,i); + PixelTrait traits=GetPixelChannelTraits(image,channel); + if (traits == UndefinedPixelTrait) + continue; + EXTEND(sp,14*(i+1)*count); + ChannelFeatures(channel,j); + } } channel_features=(ChannelFeatures *) RelinquishMagickMemory(channel_features); @@ -4698,7 +4770,7 @@ Get(ref,...) { if (image == (Image *) NULL) break; - (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g", + (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g", image->chromaticity.blue_primary.x, image->chromaticity.blue_primary.y); s=newSVpv(color,0); @@ -4767,7 +4839,7 @@ Get(ref,...) sv=NULL; if (image->read_mask == MagickFalse) ClipImage(image,exception); - mask_image=GetImageMask(image,exception); + mask_image=GetImageMask(image,ReadPixelMask,exception); if (mask_image != (Image *) NULL) { AddImageToRegistry(sv,mask_image); @@ -4790,7 +4862,7 @@ Get(ref,...) sv=NULL; if (image->read_mask != MagickFalse) ClipImage(image,exception); - mask_image=GetImageMask(image,exception); + mask_image=GetImageMask(image,ReadPixelMask,exception); if (mask_image != (Image *) NULL) { AddImageToRegistry(sv,mask_image); @@ -4891,7 +4963,7 @@ Get(ref,...) if (image == (Image *) NULL) break; - (void) FormatLocaleString(geometry,MagickPathExtent,"%.15gx%.15g", + (void) FormatLocaleString(geometry,MagickPathExtent,"%.20gx%.20g", image->resolution.x,image->resolution.y); s=newSVpv(geometry,0); PUSHs(s ? sv_2mortal(s) : &sv_undef); @@ -5083,7 +5155,7 @@ Get(ref,...) { if (image == (Image *) NULL) break; - (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g", + (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g", image->chromaticity.green_primary.x, image->chromaticity.green_primary.y); s=newSVpv(color,0); @@ -5318,10 +5390,10 @@ Get(ref,...) if (image == (Image *) NULL) break; (void) FormatLocaleString(color,MagickPathExtent, - "%.20g,%.20g,%.20g,%.20g",(double) image->matte_color.red, - (double) image->matte_color.green, - (double) image->matte_color.blue, - (double) image->matte_color.alpha); + "%.20g,%.20g,%.20g,%.20g",(double) image->alpha_color.red, + (double) image->alpha_color.green, + (double) image->alpha_color.blue, + (double) image->alpha_color.alpha); s=newSVpv(color,0); PUSHs(s ? sv_2mortal(s) : &sv_undef); continue; @@ -5474,15 +5546,6 @@ Get(ref,...) PUSHs(s ? sv_2mortal(s) : &sv_undef); continue; } - if (LocaleCompare(attribute,"preview") == 0) - { - s=newSViv(info->image_info->preview_type); - (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions, - info->image_info->preview_type)); - SvIOK_on(s); - PUSHs(s ? sv_2mortal(s) : &sv_undef); - continue; - } ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", attribute); break; @@ -5526,7 +5589,7 @@ Get(ref,...) { if (image == (Image *) NULL) break; - (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g", + (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g", image->chromaticity.red_primary.x, image->chromaticity.red_primary.y); s=newSVpv(color,0); @@ -5642,7 +5705,7 @@ Get(ref,...) { if (image == (Image *) NULL) break; - j=(ssize_t) GetImageType(image,exception); + j=(ssize_t) GetImageType(image); s=newSViv(j); (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j)); SvIOK_on(s); @@ -5700,13 +5763,6 @@ Get(ref,...) PUSHs(s ? sv_2mortal(s) : &sv_undef); continue; } - if (LocaleCompare(attribute,"view") == 0) - { - if (info && info->image_info->view) - s=newSVpv(info->image_info->view,0); - PUSHs(s ? sv_2mortal(s) : &sv_undef); - continue; - } if (LocaleCompare(attribute,"virtual-pixel") == 0) { if (image == (Image *) NULL) @@ -5730,7 +5786,7 @@ Get(ref,...) { if (image == (Image *) NULL) break; - (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g", + (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g", image->chromaticity.white_point.x, image->chromaticity.white_point.y); s=newSVpv(color,0); @@ -5751,6 +5807,21 @@ Get(ref,...) case 'X': case 'x': { + if (LocaleCompare(attribute,"xmp") == 0) + { + if (image != (Image *) NULL) + { + const StringInfo + *profile; + + profile=GetImageProfile(image,"xmp"); + if (profile != (StringInfo *) NULL) + s=newSVpv((const char *) GetStringInfoDatum(profile), + GetStringInfoLength(profile)); + } + PUSHs(s ? sv_2mortal(s) : &sv_undef); + continue; + } if (LocaleCompare(attribute,"x-resolution") == 0) { if (image != (Image *) NULL) @@ -7533,30 +7604,36 @@ Mogrify(ref,...) BrightnessContrastImage = 262 Morphology = 263 MorphologyImage = 264 - Color = 265 - ColorImage = 266 - Mode = 267 - ModeImage = 268 - Statistic = 269 - StatisticImage = 270 - Perceptible = 271 - PerceptibleImage = 272 - Poly = 273 - PolyImage = 274 - Grayscale = 275 - GrayscaleImage = 276 - CannyEdge = 278 - CannyEdgeImage = 279 - HoughLine = 280 - HoughLineImage = 281 - MeanShift = 282 - MeanShiftImage = 283 - Kuwahara = 284 - KuwaharaImage = 285 - ConnectedComponent = 286 - ConnectedComponentImage = 287 - CopyPixels = 288 - CopyImagePixels = 289 + Mode = 265 + ModeImage = 266 + Statistic = 267 + StatisticImage = 268 + Perceptible = 269 + PerceptibleImage = 270 + Poly = 271 + PolyImage = 272 + Grayscale = 273 + GrayscaleImage = 274 + CannyEdge = 275 + CannyEdgeImage = 276 + HoughLine = 277 + HoughLineImage = 278 + MeanShift = 279 + MeanShiftImage = 280 + Kuwahara = 281 + KuwaharaImage = 282 + ConnectedComponents = 283 + ConnectedComponentsImage = 284 + CopyPixels = 285 + CopyImagePixels = 286 + Color = 287 + ColorImage = 288 + WaveletDenoise = 289 + WaveletDenoiseImage= 290 + Colorspace = 291 + ColorspaceImage = 292 + AutoThreshold = 293 + AutoThresholdImage = 294 MogrifyRegion = 666 PPCODE: { @@ -8056,7 +8133,7 @@ Mogrify(ref,...) frame_info.width=image->columns+2*frame_info.x; frame_info.height=image->rows+2*frame_info.y; if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0)) - image->matte_color=fill_color; + image->alpha_color=fill_color; compose=image->compose; if (attribute_flag[7] != 0) compose=(CompositeOperator) argument_list[7].integer_reference; @@ -8265,7 +8342,7 @@ Mogrify(ref,...) method=UndefinedInterpolatePixel; if (attribute_flag[1] != 0) method=(PixelInterpolateMethod) argument_list[1].integer_reference; - image=SpreadImage(image,argument_list[0].real_reference,method, + image=SpreadImage(image,method,argument_list[0].real_reference, exception); break; } @@ -8299,7 +8376,7 @@ Mogrify(ref,...) SetImageArtifact(image,"filter:support", argument_list[4].string_reference); image=ResizeImage(image,geometry.width,geometry.height, - (FilterTypes) argument_list[3].integer_reference, + (FilterType) argument_list[3].integer_reference, exception); break; } @@ -8748,7 +8825,8 @@ Mogrify(ref,...) */ mask_image=CloneImage(argument_list[10].image_reference,0,0, MagickTrue,exception); - (void) SetImageMask(composite_image,mask_image,exception); + (void) SetImageMask(composite_image,ReadPixelMask,mask_image, + exception); mask_image=DestroyImage(mask_image); } } @@ -8786,7 +8864,8 @@ Mogrify(ref,...) (image->compose == DistortCompositeOp)) composite_image=DestroyImage(composite_image); else - (void) SetImageMask(image,(Image *) NULL,exception); + (void) SetImageMask(image,ReadPixelMask,(Image *) NULL, + exception); } (void) SetImageChannelMask(image,channel_mask); break; @@ -9070,7 +9149,7 @@ Mogrify(ref,...) if (attribute_flag[0] == 0) { (void) FormatLocaleString(message,MagickPathExtent, - "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference, + "%.20g,%.20g,%.20g",(double) argument_list[2].real_reference, (double) argument_list[3].real_reference, (double) argument_list[4].real_reference); argument_list[0].string_reference=message; @@ -9178,7 +9257,7 @@ Mogrify(ref,...) geometry_info.rho=argument_list[6].real_reference; SetImageArtifact(image,"modulate:colorspace","HWB"); } - (void) FormatLocaleString(modulate,MagickPathExtent,"%.15g,%.15g,%.15g", + (void) FormatLocaleString(modulate,MagickPathExtent,"%.20g,%.20g,%.20g", geometry_info.rho,geometry_info.sigma,geometry_info.xi); (void) ModulateImage(image,modulate,exception); break; @@ -9726,7 +9805,7 @@ Mogrify(ref,...) if (attribute_flag[1] != 0) channel=(ChannelType) argument_list[1].integer_reference; channel_mask=SetImageChannelMask(image,channel); - (void) OrderedPosterizeImage(image,argument_list[0].string_reference, + (void) OrderedDitherImage(image,argument_list[0].string_reference, exception); (void) SetImageChannelMask(image,channel_mask); break; @@ -9929,7 +10008,7 @@ Mogrify(ref,...) if (attribute_flag[1] != 0) image->fuzz=StringToDoubleInterval( argument_list[1].string_reference,(double) QuantumRange+1.0); - (void) IsImagesEqual(image,argument_list[0].image_reference, + (void) SetImageColorMetric(image,argument_list[0].image_reference, exception); break; } @@ -9978,7 +10057,7 @@ Mogrify(ref,...) (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5); height=(size_t) (geometry_info.sigma*image->rows/ (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5); - image=ResizeImage(image,width,height,(FilterTypes) + image=ResizeImage(image,width,height,(FilterType) argument_list[3].integer_reference,exception); if (image != (Image *) NULL) { @@ -10397,7 +10476,7 @@ Mogrify(ref,...) if (attribute_flag[2] != 0) geometry.height=argument_list[2].integer_reference; if (attribute_flag[3] != 0) - image->filter=(FilterTypes) argument_list[4].integer_reference; + image->filter=(FilterType) argument_list[4].integer_reference; if (attribute_flag[4] != 0) SetImageArtifact(image,"filter:support", argument_list[4].string_reference); @@ -10418,7 +10497,7 @@ Mogrify(ref,...) } mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue, exception); - (void) SetImageMask(image,mask_image,exception); + (void) SetImageMask(image,ReadPixelMask,mask_image,exception); mask_image=DestroyImage(mask_image); break; } @@ -10511,7 +10590,7 @@ Mogrify(ref,...) } mask_image=CloneImage(argument_list[0].image_reference,0,0, MagickTrue,exception); - (void) SetImageMask(image,mask_image,exception); + (void) SetImageMask(image,ReadPixelMask,mask_image,exception); mask_image=DestroyImage(mask_image); break; } @@ -10617,7 +10696,7 @@ Mogrify(ref,...) double *coordinates; - DistortImageMethod + DistortMethod method; size_t @@ -10630,7 +10709,7 @@ Mogrify(ref,...) break; method=UndefinedDistortion; if (attribute_flag[1] != 0) - method=(DistortImageMethod) argument_list[1].integer_reference; + method=(DistortMethod) argument_list[1].integer_reference; av=(AV *) argument_list[0].array_reference; number_coordinates=(size_t) av_len(av)+1; coordinates=(double *) AcquireQuantumMemory(number_coordinates, @@ -11228,7 +11307,7 @@ Mogrify(ref,...) (void) SetImageChannelMask(image,channel_mask); break; } - case 142: /* ConnectedComponent */ + case 142: /* ConnectedComponents */ { size_t connectivity; @@ -11236,7 +11315,8 @@ Mogrify(ref,...) connectivity=4; if (attribute_flag[0] != 0) connectivity=argument_list[0].integer_reference; - image=ConnectedComponentsImage(image,connectivity,exception); + image=ConnectedComponentsImage(image,connectivity, + (CCObjectInfo **) NULL,exception); break; } case 143: /* Copy */ @@ -11247,12 +11327,16 @@ Mogrify(ref,...) OffsetInfo offset; + RectangleInfo + offset_geometry; + source_image=image; if (attribute_flag[0] != 0) source_image=argument_list[0].image_reference; + SetGeometry(source_image,&geometry); if (attribute_flag[1] != 0) - flags=ParseGravityGeometry(image,argument_list[1].string_reference, - &geometry,exception); + flags=ParseGravityGeometry(source_image, + argument_list[1].string_reference,&geometry,exception); if (attribute_flag[2] != 0) geometry.width=argument_list[2].integer_reference; if (attribute_flag[3] != 0) @@ -11262,22 +11346,82 @@ Mogrify(ref,...) if (attribute_flag[5] != 0) geometry.y=argument_list[5].integer_reference; if (attribute_flag[6] != 0) - source_image->gravity=(GravityType) - argument_list[6].integer_reference; + image->gravity=(GravityType) argument_list[6].integer_reference; + SetGeometry(image,&offset_geometry); if (attribute_flag[7] != 0) - flags=ParseGravityGeometry(source_image, - argument_list[0].string_reference,&offset,exception); - offset.x=geometry.x; - offset.y=geometry.y; + flags=ParseGravityGeometry(image,argument_list[7].string_reference, + &offset_geometry,exception); + offset.x=offset_geometry.x; + offset.y=offset_geometry.y; if (attribute_flag[8] != 0) offset.x=argument_list[8].integer_reference; if (attribute_flag[9] != 0) offset.y=argument_list[9].integer_reference; - source_image=image; (void) CopyImagePixels(image,source_image,&geometry,&offset, exception); break; } + case 144: /* Color */ + { + PixelInfo + color; + + (void) QueryColorCompliance("none",AllCompliance,&color,exception); + if (attribute_flag[0] != 0) + (void) QueryColorCompliance(argument_list[0].string_reference, + AllCompliance,&color,exception); + (void) SetImageColor(image,&color,exception); + break; + } + case 145: /* WaveletDenoise */ + { + if (attribute_flag[0] != 0) + { + flags=ParseGeometry(argument_list[0].string_reference, + &geometry_info); + if ((flags & PercentValue) != 0) + { + geometry_info.rho=QuantumRange*geometry_info.rho/100.0; + geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0; + } + if ((flags & SigmaValue) == 0) + geometry_info.sigma=0.0; + } + if (attribute_flag[1] != 0) + geometry_info.rho=argument_list[1].real_reference; + if (attribute_flag[2] != 0) + geometry_info.sigma=argument_list[2].real_reference; + if (attribute_flag[3] != 0) + channel=(ChannelType) argument_list[3].integer_reference; + channel_mask=SetImageChannelMask(image,channel); + image=WaveletDenoiseImage(image,geometry_info.rho,geometry_info.sigma, + exception); + if (image != (Image *) NULL) + (void) SetImageChannelMask(image,channel_mask); + break; + } + case 146: /* Colorspace */ + { + ColorspaceType + colorspace; + + colorspace=sRGBColorspace; + if (attribute_flag[0] != 0) + colorspace=(ColorspaceType) argument_list[0].integer_reference; + (void) TransformImageColorspace(image,colorspace,exception); + break; + } + case 147: /* AutoThreshold */ + { + AutoThresholdMethod + method; + + method=UndefinedThresholdMethod; + if (attribute_flag[0] != 0) + method=(AutoThresholdMethod) argument_list[0].integer_reference; + (void) AutoThresholdImage(image,method,exception); + break; + } } if (next != (Image *) NULL) (void) CatchImageException(next); @@ -11568,9 +11712,9 @@ Montage(ref,...) if (LocaleCompare(attribute,"mattecolor") == 0) { (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance, - &montage_info->matte_color,exception); + &montage_info->alpha_color,exception); for (next=image; next; next=next->next) - next->matte_color=montage_info->matte_color; + next->alpha_color=montage_info->alpha_color; break; } if (LocaleCompare(attribute,"mode") == 0) @@ -12916,7 +13060,7 @@ QueryFontMetrics(ref,...) { draw_info->geometry=AcquireString((char *) NULL); (void) FormatLocaleString(draw_info->geometry,MagickPathExtent, - "%.15g,%.15g",x,y); + "%.20g,%.20g",x,y); } status=GetTypeMetrics(image,draw_info,&metrics,exception); (void) CatchImageException(image); @@ -13289,7 +13433,7 @@ QueryMultilineFontMetrics(ref,...) { draw_info->geometry=AcquireString((char *) NULL); (void) FormatLocaleString(draw_info->geometry,MagickPathExtent, - "%.15g,%.15g",x,y); + "%.20g,%.20g",x,y); } status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception); (void) CatchException(exception); @@ -14235,25 +14379,25 @@ Statistics(ref,...) (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ (double) channel_statistics[channel].depth); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ - channel_statistics[channel].minima/scale); \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ + channel_statistics[channel].minima/QuantumRange); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ - channel_statistics[channel].maxima/scale); \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ + channel_statistics[channel].maxima/QuantumRange); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ - channel_statistics[channel].mean/scale); \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ + channel_statistics[channel].mean/QuantumRange); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ - channel_statistics[channel].standard_deviation/scale); \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ + channel_statistics[channel].standard_deviation/QuantumRange); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_statistics[channel].kurtosis); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_statistics[channel].skewness); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ - (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \ + (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \ channel_statistics[channel].entropy); \ PUSHs(sv_2mortal(newSVpv(message,0))); \ } @@ -14267,9 +14411,6 @@ Statistics(ref,...) ChannelStatistics *channel_statistics; - double - scale; - ExceptionInfo *exception; @@ -14310,19 +14451,24 @@ Statistics(ref,...) count=0; for ( ; image; image=image->next) { + register size_t + i; + channel_statistics=GetImageStatistics(image,exception); if (channel_statistics == (ChannelStatistics *) NULL) continue; count++; - EXTEND(sp,35*count); - scale=(double) QuantumRange; - ChannelStatistics(RedChannel); - ChannelStatistics(GreenChannel); - ChannelStatistics(BlueChannel); - if (image->colorspace == CMYKColorspace) - ChannelStatistics(BlackChannel); - if (image->alpha_trait != UndefinedPixelTrait) - ChannelStatistics(AlphaChannel); + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel channel=GetPixelChannelChannel(image,i); + PixelTrait traits=GetPixelChannelTraits(image,channel); + if (traits == UndefinedPixelTrait) + continue; + EXTEND(sp,8*(i+1)*count); + ChannelStatistics(channel); + } + EXTEND(sp,8*(i+1)*count); + ChannelStatistics(CompositePixelChannel); channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(channel_statistics); } @@ -14405,154 +14551,6 @@ SyncAuthenticPixels(ref,...) # # # # # # -# T r a n s f o r m # -# # -# # -# # -############################################################################### -# -# -void -Transform(ref,...) - Image::Magick ref=NO_INIT - ALIAS: - TransformImage = 1 - transform = 2 - transformimage = 3 - PPCODE: - { - AV - *av; - - char - *attribute, - *crop_geometry, - *geometry; - - ExceptionInfo - *exception; - - HV - *hv; - - Image - *clone, - *image; - - register ssize_t - i; - - struct PackageInfo - *info; - - SV - *av_reference, - *perl_exception, - *reference, - *rv, - *sv; - - PERL_UNUSED_VAR(ref); - PERL_UNUSED_VAR(ix); - exception=AcquireExceptionInfo(); - perl_exception=newSVpv("",0); - sv=NULL; - av=NULL; - attribute=NULL; - if (sv_isobject(ST(0)) == 0) - { - ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType", - PackageName); - goto PerlException; - } - reference=SvRV(ST(0)); - hv=SvSTASH(reference); - av=newAV(); - av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv)); - SvREFCNT_dec(av); - image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception); - if (image == (Image *) NULL) - { - ThrowPerlException(exception,OptionError,"NoImagesDefined", - PackageName); - goto PerlException; - } - info=GetPackageInfo(aTHX_ (void *) av,info,exception); - /* - Get attribute. - */ - crop_geometry=(char *) NULL; - geometry=(char *) NULL; - for (i=2; i < items; i+=2) - { - attribute=(char *) SvPV(ST(i-1),na); - switch (*attribute) - { - case 'c': - case 'C': - { - if (LocaleCompare(attribute,"crop") == 0) - { - crop_geometry=SvPV(ST(i),na); - break; - } - ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", - attribute); - break; - } - case 'g': - case 'G': - { - if (LocaleCompare(attribute,"geometry") == 0) - { - geometry=SvPV(ST(i),na); - break; - } - ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", - attribute); - break; - } - default: - { - ThrowPerlException(exception,OptionError,"UnrecognizedAttribute", - attribute); - break; - } - } - } - for ( ; image; image=image->next) - { - clone=CloneImage(image,0,0,MagickTrue,exception); - if (clone == (Image *) NULL) - goto PerlException; - TransformImage(&clone,crop_geometry,geometry,exception); - for ( ; clone; clone=clone->next) - { - AddImageToRegistry(sv,clone); - rv=newRV(sv); - av_push(av,sv_bless(rv,hv)); - SvREFCNT_dec(sv); - } - } - exception=DestroyExceptionInfo(exception); - ST(0)=av_reference; - SvREFCNT_dec(perl_exception); /* can't return warning messages */ - XSRETURN(1); - - PerlException: - InheritPerlException(exception,perl_exception); - exception=DestroyExceptionInfo(exception); - sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0); - SvPOK_on(perl_exception); - ST(0)=sv_2mortal(perl_exception); - XSRETURN(1); - } - -# -############################################################################### -# # -# # -# # # W r i t e # # # # #