2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % AAA TTTTT TTTTT RRRR IIIII BBBB U U TTTTT EEEEE %
7 % A A T T R R I B B U U T E %
8 % AAAAA T T RRRR I BBBB U U T EEE %
9 % A A T T R R I B B U U T E %
10 % A A T T R R IIIII BBBB UUU T EEEEE %
13 % MagickCore Get / Set Image Attributes %
20 % Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "magick/studio.h"
44 #include "magick/attribute.h"
45 #include "magick/blob.h"
46 #include "magick/blob-private.h"
47 #include "magick/cache.h"
48 #include "magick/cache-view.h"
49 #include "magick/client.h"
50 #include "magick/color.h"
51 #include "magick/color-private.h"
52 #include "magick/colormap.h"
53 #include "magick/colormap-private.h"
54 #include "magick/colorspace.h"
55 #include "magick/composite.h"
56 #include "magick/composite-private.h"
57 #include "magick/constitute.h"
58 #include "magick/deprecate.h"
59 #include "magick/draw.h"
60 #include "magick/draw-private.h"
61 #include "magick/effect.h"
62 #include "magick/enhance.h"
63 #include "magick/exception.h"
64 #include "magick/exception-private.h"
65 #include "magick/geometry.h"
66 #include "magick/histogram.h"
67 #include "magick/identify.h"
68 #include "magick/image.h"
69 #include "magick/image-private.h"
70 #include "magick/list.h"
71 #include "magick/log.h"
72 #include "magick/memory_.h"
73 #include "magick/magick.h"
74 #include "magick/monitor.h"
75 #include "magick/monitor-private.h"
76 #include "magick/paint.h"
77 #include "magick/pixel.h"
78 #include "magick/pixel-private.h"
79 #include "magick/property.h"
80 #include "magick/quantize.h"
81 #include "magick/random_.h"
82 #include "magick/resource_.h"
83 #include "magick/semaphore.h"
84 #include "magick/segment.h"
85 #include "magick/splay-tree.h"
86 #include "magick/string_.h"
87 #include "magick/thread-private.h"
88 #include "magick/threshold.h"
89 #include "magick/transform.h"
90 #include "magick/utility.h"
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97 + G e t I m a g e B o u n d i n g B o x %
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 % GetImageBoundingBox() returns the bounding box of an image canvas.
105 % The format of the GetImageBoundingBox method is:
107 % RectangleInfo GetImageBoundingBox(const Image *image,
108 % ExceptionInfo *exception)
110 % A description of each parameter follows:
112 % o bounds: Method GetImageBoundingBox returns the bounding box of an
115 % o image: the image.
117 % o exception: return any errors or warnings in this structure.
120 MagickExport RectangleInfo GetImageBoundingBox(const Image *image,
121 ExceptionInfo *exception)
136 register const PixelPacket
142 assert(image != (Image *) NULL);
143 assert(image->signature == MagickSignature);
144 if (image->debug != MagickFalse)
145 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
148 bounds.x=(long) image->columns;
149 bounds.y=(long) image->rows;
150 GetMagickPixelPacket(image,&target[0]);
151 image_view=AcquireCacheView(image);
152 p=GetCacheViewVirtualPixels(image_view,0,0,1,1,exception);
153 if (p == (const PixelPacket *) NULL)
155 image_view=DestroyCacheView(image_view);
158 SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
160 GetMagickPixelPacket(image,&target[1]);
161 p=GetCacheViewVirtualPixels(image_view,(long) image->columns-1,0,1,1,
163 SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
165 GetMagickPixelPacket(image,&target[2]);
166 p=GetCacheViewVirtualPixels(image_view,0,(long) image->rows-1,1,1,exception);
167 SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
170 GetMagickPixelPacket(image,&zero);
171 #if defined(_OPENMP) && (_OPENMP >= 200203)
172 #pragma omp parallel for shared(status)
174 for (y=0; y < (long) image->rows; y++)
182 register const IndexPacket
185 register const PixelPacket
191 if (status == MagickFalse)
193 #if defined(HAVE_OPENMP)
194 # pragma omp critical (MagickCore_GetImageBoundingBox)
197 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
198 if (p == (const PixelPacket *) NULL)
203 indexes=GetCacheViewVirtualIndexQueue(image_view);
205 for (x=0; x < (long) image->columns; x++)
207 SetMagickPixelPacket(image,p,indexes+x,&pixel);
208 if ((x < bounding_box.x) &&
209 (IsMagickColorSimilar(&pixel,&target[0]) == MagickFalse))
211 if ((x > (long) bounding_box.width) &&
212 (IsMagickColorSimilar(&pixel,&target[1]) == MagickFalse))
213 bounding_box.width=(unsigned long) x;
214 if ((y < bounding_box.y) &&
215 (IsMagickColorSimilar(&pixel,&target[0]) == MagickFalse))
217 if ((y > (long) bounding_box.height) &&
218 (IsMagickColorSimilar(&pixel,&target[2]) == MagickFalse))
219 bounding_box.height=(unsigned long) y;
222 #if defined(HAVE_OPENMP)
223 # pragma omp critical (MagickCore_GetImageBoundingBox)
226 if (bounding_box.x < bounds.x)
227 bounds.x=bounding_box.x;
228 if (bounding_box.y < bounds.y)
229 bounds.y=bounding_box.y;
230 if (bounding_box.width > bounds.width)
231 bounds.width=bounding_box.width;
232 if (bounding_box.height > bounds.height)
233 bounds.height=bounding_box.height;
236 image_view=DestroyCacheView(image_view);
237 if ((bounds.width == 0) || (bounds.height == 0))
238 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
239 "GeometryDoesNotContainImage","`%s'",image->filename);
242 bounds.width-=(bounds.x-1);
243 bounds.height-=(bounds.y-1);
249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
253 % G e t I m a g e C h a n n e l D e p t h %
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 % GetImageChannelDepth() returns the depth of a particular image channel.
261 % The format of the GetImageChannelDepth method is:
263 % unsigned long GetImageDepth(const Image *image,ExceptionInfo *exception)
264 % unsigned long GetImageChannelDepth(const Image *image,
265 % const ChannelType channel,ExceptionInfo *exception)
267 % A description of each parameter follows:
269 % o image: the image.
271 % o channel: the channel.
273 % o exception: return any errors or warnings in this structure.
277 MagickExport unsigned long GetImageDepth(const Image *image,
278 ExceptionInfo *exception)
280 return(GetImageChannelDepth(image,AllChannels,exception));
283 MagickExport unsigned long GetImageChannelDepth(const Image *image,
284 const ChannelType channel,ExceptionInfo *exception)
306 assert(image != (Image *) NULL);
307 assert(image->signature == MagickSignature);
308 if (image->debug != MagickFalse)
309 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
310 number_threads=GetOpenMPMaximumThreads();
311 current_depth=(unsigned long *) AcquireQuantumMemory(number_threads,
312 sizeof(*current_depth));
313 if (current_depth == (unsigned long *) NULL)
314 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
316 for (id=0; id < (long) number_threads; id++)
318 if ((image->storage_class == PseudoClass) && (image->matte == MagickFalse))
320 register const PixelPacket
327 #if defined(_OPENMP) && (_OPENMP >= 200203)
328 #pragma omp parallel for shared(status)
330 for (i=0; i < (long) image->colors; i++)
332 if (status == MagickFalse)
334 id=GetOpenMPThreadId();
335 while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
344 range=GetQuantumRange(current_depth[id]);
345 if ((channel & RedChannel) != 0)
346 status|=p->red != ScaleAnyToQuantum(ScaleQuantumToAny(p->red,
348 if ((channel & GreenChannel) != 0)
349 status|=p->green != ScaleAnyToQuantum(ScaleQuantumToAny(p->green,
351 if ((channel & BlueChannel) != 0)
352 status|=p->blue != ScaleAnyToQuantum(ScaleQuantumToAny(p->blue,
360 depth=current_depth[0];
361 for (id=1; id < (long) number_threads; id++)
362 if (depth < current_depth[id])
363 depth=current_depth[id];
364 current_depth=(unsigned long *) RelinquishMagickMemory(current_depth);
367 image_view=AcquireCacheView(image);
368 #if defined(_OPENMP) && (_OPENMP >= 200203)
369 #pragma omp parallel for shared(status)
371 for (y=0; y < (long) image->rows; y++)
373 register const IndexPacket
376 register const PixelPacket
383 if (status == MagickFalse)
385 id=GetOpenMPThreadId();
386 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
387 if (p == (const PixelPacket *) NULL)
389 indexes=GetCacheViewVirtualIndexQueue(image_view);
390 for (x=0; x < (long) image->columns; x++)
392 while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
401 range=GetQuantumRange(current_depth[id]);
402 if ((channel & RedChannel) != 0)
403 status|=p->red != ScaleAnyToQuantum(ScaleQuantumToAny(p->red,range),
405 if ((channel & GreenChannel) != 0)
406 status|=p->green != ScaleAnyToQuantum(ScaleQuantumToAny(p->green,
408 if ((channel & BlueChannel) != 0)
409 status|=p->blue != ScaleAnyToQuantum(ScaleQuantumToAny(p->blue,range),
411 if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse))
412 status|=p->opacity != ScaleAnyToQuantum(ScaleQuantumToAny(p->opacity,
414 if (((channel & IndexChannel) != 0) &&
415 (image->colorspace == CMYKColorspace))
416 status|=indexes[x] != ScaleAnyToQuantum(ScaleQuantumToAny(indexes[x],
424 if (current_depth[id] == MAGICKCORE_QUANTUM_DEPTH)
427 image_view=DestroyCacheView(image_view);
428 depth=current_depth[0];
429 for (id=1; id < (long) number_threads; id++)
430 if (depth < current_depth[id])
431 depth=current_depth[id];
432 current_depth=(unsigned long *) RelinquishMagickMemory(current_depth);
437 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
441 % G e t I m a g e Q u a n t u m D e p t h %
445 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
447 % GetImageQuantumDepth() returns the depth of the image rounded to a legal
448 % quantum depth: 8, 16, or 32.
450 % The format of the GetImageQuantumDepth method is:
452 % unsigned long GetImageQuantumDepth(const Image *image,
453 % const MagickBooleanType constrain)
455 % A description of each parameter follows:
457 % o image: the image.
459 % o constrain: A value other than MagickFalse, constrains the depth to
460 % a maximum of MAGICKCORE_QUANTUM_DEPTH.
464 static inline double MagickMin(const double x,const double y)
471 MagickExport unsigned long GetImageQuantumDepth(const Image *image,
472 const MagickBooleanType constrain)
489 if (constrain != MagickFalse)
490 depth=(unsigned long) MagickMin((double) depth,(double)
491 MAGICKCORE_QUANTUM_DEPTH);
496 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
500 % G e t I m a g e T y p e %
504 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
506 % GetImageType() returns the potential type of image:
508 % Bilevel Grayscale GrayscaleMatte
509 % Palette PaletteMatte TrueColor
510 % TrueColorMatte ColorSeparation ColorSeparationMatte
512 % To ensure the image type matches its potential, use SetImageType():
514 % (void) SetImageType(image,GetImageType(image));
516 % The format of the GetImageType method is:
518 % ImageType GetImageType(const Image *image,ExceptionInfo *exception)
520 % A description of each parameter follows:
522 % o image: the image.
524 % o exception: return any errors or warnings in this structure.
527 MagickExport ImageType GetImageType(const Image *image,ExceptionInfo *exception)
529 assert(image != (Image *) NULL);
530 assert(image->signature == MagickSignature);
531 if (image->debug != MagickFalse)
532 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
533 if (image->colorspace == CMYKColorspace)
535 if (image->matte == MagickFalse)
536 return(ColorSeparationType);
537 return(ColorSeparationMatteType);
539 if (IsMonochromeImage(image,exception) != MagickFalse)
541 if (IsGrayImage(image,exception) != MagickFalse)
543 if (image->matte != MagickFalse)
544 return(GrayscaleMatteType);
545 return(GrayscaleType);
547 if (IsPaletteImage(image,exception) != MagickFalse)
549 if (image->matte != MagickFalse)
550 return(PaletteMatteType);
553 if (image->matte != MagickFalse)
554 return(TrueColorMatteType);
555 return(TrueColorType);
559 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
563 % I s G r a y I m a g e %
567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
569 % IsGrayImage() returns MagickTrue if all the pixels in the image have the
570 % same red, green, and blue intensities.
572 % The format of the IsGrayImage method is:
574 % MagickBooleanType IsGrayImage(const Image *image,
575 % ExceptionInfo *exception)
577 % A description of each parameter follows:
579 % o image: the image.
581 % o exception: return any errors or warnings in this structure.
584 MagickExport MagickBooleanType IsGrayImage(const Image *image,
585 ExceptionInfo *exception)
590 register const PixelPacket
593 assert(image != (Image *) NULL);
594 assert(image->signature == MagickSignature);
595 if (image->debug != MagickFalse)
596 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
597 if ((image->type == BilevelType) || (image->type == GrayscaleType) ||
598 (image->type == GrayscaleMatteType))
600 if (image->colorspace == CMYKColorspace)
603 switch (image->storage_class)
617 image_view=AcquireCacheView(image);
618 for (y=0; y < (long) image->rows; y++)
620 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
621 if (p == (const PixelPacket *) NULL)
623 for (x=0; x < (long) image->columns; x++)
625 if (IsGrayPixel(p) == MagickFalse)
630 if ((type == BilevelType) && (IsMonochromePixel(p) == MagickFalse))
634 if (type == UndefinedType)
637 image_view=DestroyCacheView(image_view);
646 for (i=0; i < (long) image->colors; i++)
648 if (IsGrayPixel(p) == MagickFalse)
653 if ((type == BilevelType) && (IsMonochromePixel(p) == MagickFalse))
660 if (type == UndefinedType)
662 ((Image *) image)->type=type;
663 if ((type == GrayscaleType) && (image->matte != MagickFalse))
664 ((Image *) image)->type=GrayscaleMatteType;
669 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
673 % I s M o n o c h r o m e I m a g e %
677 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
679 % IsMonochromeImage() returns MagickTrue if all the pixels in the image have
680 % the same red, green, and blue intensities and the intensity is either
683 % The format of the IsMonochromeImage method is:
685 % MagickBooleanType IsMonochromeImage(const Image *image,
686 % ExceptionInfo *exception)
688 % A description of each parameter follows:
690 % o image: the image.
692 % o exception: return any errors or warnings in this structure.
695 MagickExport MagickBooleanType IsMonochromeImage(const Image *image,
696 ExceptionInfo *exception)
701 register const PixelPacket
704 assert(image != (Image *) NULL);
705 assert(image->signature == MagickSignature);
706 if (image->debug != MagickFalse)
707 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
708 if (image->type == BilevelType)
710 if (image->colorspace == CMYKColorspace)
713 switch (image->storage_class)
727 image_view=AcquireCacheView(image);
728 for (y=0; y < (long) image->rows; y++)
730 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
731 if (p == (const PixelPacket *) NULL)
733 for (x=0; x < (long) image->columns; x++)
735 if (IsMonochromePixel(p) == MagickFalse)
742 if (type == UndefinedType)
745 image_view=DestroyCacheView(image_view);
746 if (y == (long) image->rows)
747 ((Image *) image)->type=BilevelType;
756 for (i=0; i < (long) image->colors; i++)
758 if (IsMonochromePixel(p) == MagickFalse)
768 if (type == UndefinedType)
770 ((Image *) image)->type=type;
775 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
779 % I s O p a q u e I m a g e %
783 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
785 % IsOpaqueImage() returns MagickTrue if none of the pixels in the image have
786 % an opacity value other than opaque (0).
788 % The format of the IsOpaqueImage method is:
790 % MagickBooleanType IsOpaqueImage(const Image *image,
791 % ExceptionInfo *exception)
793 % A description of each parameter follows:
795 % o image: the image.
797 % o exception: return any errors or warnings in this structure.
800 MagickExport MagickBooleanType IsOpaqueImage(const Image *image,
801 ExceptionInfo *exception)
806 register const PixelPacket
816 Determine if image is opaque.
818 assert(image != (Image *) NULL);
819 assert(image->signature == MagickSignature);
820 if (image->debug != MagickFalse)
821 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
822 if (image->matte == MagickFalse)
824 image_view=AcquireCacheView(image);
825 for (y=0; y < (long) image->rows; y++)
827 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
828 if (p == (const PixelPacket *) NULL)
830 for (x=0; x < (long) image->columns; x++)
832 if (p->opacity != OpaqueOpacity)
836 if (x < (long) image->columns)
839 image_view=DestroyCacheView(image_view);
840 return(y < (long) image->rows ? MagickFalse : MagickTrue);
844 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
848 % S e t I m a g e C h a n n e l D e p t h %
852 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
854 % SetImageChannelDepth() sets the depth of the image.
856 % The format of the SetImageChannelDepth method is:
858 % MagickBooleanType SetImageDepth(Image *image,const unsigned long depth)
859 % MagickBooleanType SetImageChannelDepth(Image *image,
860 % const ChannelType channel,const unsigned long depth)
862 % A description of each parameter follows:
864 % o image: the image.
866 % o channel: the channel.
868 % o depth: the image depth.
872 MagickExport MagickBooleanType SetImageDepth(Image *image,
873 const unsigned long depth)
875 return(SetImageChannelDepth(image,AllChannels,depth));
878 MagickExport MagickBooleanType SetImageChannelDepth(Image *image,
879 const ChannelType channel,const unsigned long depth)
896 assert(image != (Image *) NULL);
897 if (image->debug != MagickFalse)
898 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
899 assert(image->signature == MagickSignature);
900 if (GetImageDepth(image,&image->exception) <= (unsigned long)
901 MagickMin((double) depth,(double) MAGICKCORE_QUANTUM_DEPTH))
907 Scale pixels to desired depth.
910 range=GetQuantumRange(depth);
911 exception=(&image->exception);
912 image_view=AcquireCacheView(image);
913 #if defined(_OPENMP) && (_OPENMP >= 200203)
914 #pragma omp parallel for shared(status)
916 for (y=0; y < (long) image->rows; y++)
927 if (status == MagickFalse)
929 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
931 if (q == (PixelPacket *) NULL)
936 indexes=GetCacheViewAuthenticIndexQueue(image_view);
937 for (x=0; x < (long) image->columns; x++)
939 if ((channel & RedChannel) != 0)
940 q->red=ScaleAnyToQuantum(ScaleQuantumToAny(q->red,range),range);
941 if ((channel & GreenChannel) != 0)
942 q->green=ScaleAnyToQuantum(ScaleQuantumToAny(q->green,range),range);
943 if ((channel & BlueChannel) != 0)
944 q->blue=ScaleAnyToQuantum(ScaleQuantumToAny(q->blue,range),range);
945 if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse))
946 q->opacity=ScaleAnyToQuantum(ScaleQuantumToAny(q->opacity,range),range);
947 if (((channel & IndexChannel) != 0) &&
948 (image->colorspace == CMYKColorspace))
949 indexes[x]=ScaleAnyToQuantum(ScaleQuantumToAny(indexes[x],range),range);
952 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
958 image_view=DestroyCacheView(image_view);
959 if (image->storage_class == PseudoClass)
971 range=GetQuantumRange(depth);
972 #if defined(_OPENMP) && (_OPENMP >= 200203)
973 #pragma omp parallel for shared(status)
975 for (i=0; i < (long) image->colors; i++)
977 if ((channel & RedChannel) != 0)
978 p->red=ScaleAnyToQuantum(ScaleQuantumToAny(p->red,range),range);
979 if ((channel & GreenChannel) != 0)
980 p->green=ScaleAnyToQuantum(ScaleQuantumToAny(p->green,range),range);
981 if ((channel & BlueChannel) != 0)
982 p->blue=ScaleAnyToQuantum(ScaleQuantumToAny(p->blue,range),range);
983 if ((channel & OpacityChannel) != 0)
984 p->opacity=ScaleAnyToQuantum(ScaleQuantumToAny(p->opacity,range),