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-2011 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=(ssize_t) image->columns;
149 bounds.y=(ssize_t) 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,(ssize_t) image->columns-1,0,1,1,
163 SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
165 GetMagickPixelPacket(image,&target[2]);
166 p=GetCacheViewVirtualPixels(image_view,0,(ssize_t) image->rows-1,1,1,
168 SetMagickPixelPacket(image,p,GetCacheViewAuthenticIndexQueue(image_view),
171 GetMagickPixelPacket(image,&zero);
172 #if defined(MAGICKCORE_OPENMP_SUPPORT)
173 #pragma omp parallel for schedule(dynamic,4) shared(status)
175 for (y=0; y < (ssize_t) image->rows; y++)
183 register const IndexPacket
186 register const PixelPacket
192 if (status == MagickFalse)
194 #if defined(MAGICKCORE_OPENMP_SUPPORT)
195 # pragma omp critical (MagickCore_GetImageBoundingBox)
198 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
199 if (p == (const PixelPacket *) NULL)
204 indexes=GetCacheViewVirtualIndexQueue(image_view);
206 for (x=0; x < (ssize_t) image->columns; x++)
208 SetMagickPixelPacket(image,p,indexes+x,&pixel);
209 if ((x < bounding_box.x) &&
210 (IsMagickColorSimilar(&pixel,&target[0]) == MagickFalse))
212 if ((x > (ssize_t) bounding_box.width) &&
213 (IsMagickColorSimilar(&pixel,&target[1]) == MagickFalse))
214 bounding_box.width=(size_t) x;
215 if ((y < bounding_box.y) &&
216 (IsMagickColorSimilar(&pixel,&target[0]) == MagickFalse))
218 if ((y > (ssize_t) bounding_box.height) &&
219 (IsMagickColorSimilar(&pixel,&target[2]) == MagickFalse))
220 bounding_box.height=(size_t) y;
223 #if defined(MAGICKCORE_OPENMP_SUPPORT)
224 # pragma omp critical (MagickCore_GetImageBoundingBox)
227 if (bounding_box.x < bounds.x)
228 bounds.x=bounding_box.x;
229 if (bounding_box.y < bounds.y)
230 bounds.y=bounding_box.y;
231 if (bounding_box.width > bounds.width)
232 bounds.width=bounding_box.width;
233 if (bounding_box.height > bounds.height)
234 bounds.height=bounding_box.height;
237 image_view=DestroyCacheView(image_view);
238 if ((bounds.width == 0) || (bounds.height == 0))
239 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
240 "GeometryDoesNotContainImage","`%s'",image->filename);
243 bounds.width-=(bounds.x-1);
244 bounds.height-=(bounds.y-1);
250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254 % G e t I m a g e C h a n n e l D e p t h %
258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260 % GetImageChannelDepth() returns the depth of a particular image channel.
262 % The format of the GetImageChannelDepth method is:
264 % size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
265 % size_t GetImageChannelDepth(const Image *image,
266 % const ChannelType channel,ExceptionInfo *exception)
268 % A description of each parameter follows:
270 % o image: the image.
272 % o channel: the channel.
274 % o exception: return any errors or warnings in this structure.
277 MagickExport size_t GetImageDepth(const Image *image,ExceptionInfo *exception)
279 return(GetImageChannelDepth(image,CompositeChannels,exception));
282 MagickExport size_t GetImageChannelDepth(const Image *image,
283 const ChannelType channel,ExceptionInfo *exception)
305 assert(image != (Image *) NULL);
306 assert(image->signature == MagickSignature);
307 if (image->debug != MagickFalse)
308 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
309 number_threads=GetOpenMPMaximumThreads();
310 current_depth=(size_t *) AcquireQuantumMemory(number_threads,
311 sizeof(*current_depth));
312 if (current_depth == (size_t *) NULL)
313 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
315 for (id=0; id < (ssize_t) number_threads; id++)
317 if ((image->storage_class == PseudoClass) && (image->matte == MagickFalse))
319 register const PixelPacket
326 #if defined(MAGICKCORE_OPENMP_SUPPORT)
327 #pragma omp parallel for schedule(dynamic,4) shared(status)
329 for (i=0; i < (ssize_t) image->colors; i++)
332 id = GetOpenMPThreadId();
334 if (status == MagickFalse)
336 while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
345 range=GetQuantumRange(current_depth[id]);
346 if ((channel & RedChannel) != 0)
347 status|=GetRedPixelComponent(p) != ScaleAnyToQuantum(ScaleQuantumToAny(GetRedPixelComponent(p),
349 if ((channel & GreenChannel) != 0)
350 status|=GetGreenPixelComponent(p) != ScaleAnyToQuantum(ScaleQuantumToAny(GetGreenPixelComponent(p),
352 if ((channel & BlueChannel) != 0)
353 status|=GetBluePixelComponent(p) != ScaleAnyToQuantum(ScaleQuantumToAny(GetBluePixelComponent(p),
361 depth=current_depth[0];
362 for (id=1; id < (ssize_t) number_threads; id++)
363 if (depth < current_depth[id])
364 depth=current_depth[id];
365 current_depth=(size_t *) RelinquishMagickMemory(current_depth);
368 image_view=AcquireCacheView(image);
369 #if defined(MAGICKCORE_OPENMP_SUPPORT)
370 #pragma omp parallel for schedule(dynamic,4) shared(status)
372 for (y=0; y < (ssize_t) image->rows; y++)
375 id = GetOpenMPThreadId();
377 register const IndexPacket
380 register const PixelPacket
386 if (status == MagickFalse)
388 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
389 if (p == (const PixelPacket *) NULL)
391 indexes=GetCacheViewVirtualIndexQueue(image_view);
392 for (x=0; x < (ssize_t) image->columns; x++)
394 while (current_depth[id] < MAGICKCORE_QUANTUM_DEPTH)
403 range=GetQuantumRange(current_depth[id]);
404 if ((channel & RedChannel) != 0)
405 status|=GetRedPixelComponent(p) != ScaleAnyToQuantum(
406 ScaleQuantumToAny(GetRedPixelComponent(p),range),range);
407 if ((channel & GreenChannel) != 0)
408 status|=GetGreenPixelComponent(p) != ScaleAnyToQuantum(
409 ScaleQuantumToAny(GetGreenPixelComponent(p),range),range);
410 if ((channel & BlueChannel) != 0)
411 status|=GetBluePixelComponent(p) != ScaleAnyToQuantum(
412 ScaleQuantumToAny(GetBluePixelComponent(p),range),range);
413 if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse))
414 status|=GetOpacityPixelComponent(p) != ScaleAnyToQuantum(
415 ScaleQuantumToAny(GetOpacityPixelComponent(p),range),range);
416 if (((channel & IndexChannel) != 0) &&
417 (image->colorspace == CMYKColorspace))
418 status|=GetIndexPixelComponent(indexes+x) !=
419 ScaleAnyToQuantum(ScaleQuantumToAny(GetIndexPixelComponent(indexes+
427 if (current_depth[id] == MAGICKCORE_QUANTUM_DEPTH)
430 image_view=DestroyCacheView(image_view);
431 depth=current_depth[0];
432 for (id=1; id < (ssize_t) number_threads; id++)
433 if (depth < current_depth[id])
434 depth=current_depth[id];
435 current_depth=(size_t *) RelinquishMagickMemory(current_depth);
440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
444 % G e t I m a g e Q u a n t u m D e p t h %
448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
450 % GetImageQuantumDepth() returns the depth of the image rounded to a legal
451 % quantum depth: 8, 16, or 32.
453 % The format of the GetImageQuantumDepth method is:
455 % size_t GetImageQuantumDepth(const Image *image,
456 % const MagickBooleanType constrain)
458 % A description of each parameter follows:
460 % o image: the image.
462 % o constrain: A value other than MagickFalse, constrains the depth to
463 % a maximum of MAGICKCORE_QUANTUM_DEPTH.
467 static inline double MagickMin(const double x,const double y)
474 MagickExport size_t GetImageQuantumDepth(const Image *image,
475 const MagickBooleanType constrain)
492 if (constrain != MagickFalse)
493 depth=(size_t) MagickMin((double) depth,(double)
494 MAGICKCORE_QUANTUM_DEPTH);
499 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
503 % G e t I m a g e T y p e %
507 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
509 % GetImageType() returns the potential type of image:
511 % Bilevel Grayscale GrayscaleMatte
512 % Palette PaletteMatte TrueColor
513 % TrueColorMatte ColorSeparation ColorSeparationMatte
515 % To ensure the image type matches its potential, use SetImageType():
517 % (void) SetImageType(image,GetImageType(image));
519 % The format of the GetImageType method is:
521 % ImageType GetImageType(const Image *image,ExceptionInfo *exception)
523 % A description of each parameter follows:
525 % o image: the image.
527 % o exception: return any errors or warnings in this structure.
530 MagickExport ImageType GetImageType(const Image *image,ExceptionInfo *exception)
532 assert(image != (Image *) NULL);
533 assert(image->signature == MagickSignature);
534 if (image->debug != MagickFalse)
535 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
536 if (image->colorspace == CMYKColorspace)
538 if (image->matte == MagickFalse)
539 return(ColorSeparationType);
540 return(ColorSeparationMatteType);
542 if (IsMonochromeImage(image,exception) != MagickFalse)
544 if (IsGrayImage(image,exception) != MagickFalse)
546 if (image->matte != MagickFalse)
547 return(GrayscaleMatteType);
548 return(GrayscaleType);
550 if (IsPaletteImage(image,exception) != MagickFalse)
552 if (image->matte != MagickFalse)
553 return(PaletteMatteType);
556 if (image->matte != MagickFalse)
557 return(TrueColorMatteType);
558 return(TrueColorType);
562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
566 % I s G r a y I m a g e %
570 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
572 % IsGrayImage() returns MagickTrue if all the pixels in the image have the
573 % same red, green, and blue intensities.
575 % The format of the IsGrayImage method is:
577 % MagickBooleanType IsGrayImage(const Image *image,
578 % ExceptionInfo *exception)
580 % A description of each parameter follows:
582 % o image: the image.
584 % o exception: return any errors or warnings in this structure.
587 MagickExport MagickBooleanType IsGrayImage(const Image *image,
588 ExceptionInfo *exception)
596 register const PixelPacket
605 assert(image != (Image *) NULL);
606 assert(image->signature == MagickSignature);
607 if (image->debug != MagickFalse)
608 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
609 if ((image->type == BilevelType) || (image->type == GrayscaleType) ||
610 (image->type == GrayscaleMatteType))
612 if (image->colorspace == CMYKColorspace)
615 image_view=AcquireCacheView(image);
616 for (y=0; y < (ssize_t) image->rows; y++)
618 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
619 if (p == (const PixelPacket *) NULL)
621 for (x=0; x < (ssize_t) image->columns; x++)
623 if (IsGrayPixel(p) == MagickFalse)
628 if ((type == BilevelType) && (IsMonochromePixel(p) == MagickFalse))
632 if (type == UndefinedType)
635 image_view=DestroyCacheView(image_view);
636 if (type == UndefinedType)
638 ((Image *) image)->type=type;
639 if ((type == GrayscaleType) && (image->matte != MagickFalse))
640 ((Image *) image)->type=GrayscaleMatteType;
645 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
649 % I s M o n o c h r o m e I m a g e %
653 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
655 % IsMonochromeImage() returns MagickTrue if all the pixels in the image have
656 % the same red, green, and blue intensities and the intensity is either
659 % The format of the IsMonochromeImage method is:
661 % MagickBooleanType IsMonochromeImage(const Image *image,
662 % ExceptionInfo *exception)
664 % A description of each parameter follows:
666 % o image: the image.
668 % o exception: return any errors or warnings in this structure.
671 MagickExport MagickBooleanType IsMonochromeImage(const Image *image,
672 ExceptionInfo *exception)
683 register const PixelPacket
689 assert(image != (Image *) NULL);
690 assert(image->signature == MagickSignature);
691 if (image->debug != MagickFalse)
692 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
693 if (image->type == BilevelType)
695 if (image->colorspace == CMYKColorspace)
698 image_view=AcquireCacheView(image);
699 for (y=0; y < (ssize_t) image->rows; y++)
701 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
702 if (p == (const PixelPacket *) NULL)
704 for (x=0; x < (ssize_t) image->columns; x++)
706 if (IsMonochromePixel(p) == MagickFalse)
713 if (type == UndefinedType)
716 image_view=DestroyCacheView(image_view);
717 if (type == UndefinedType)
719 ((Image *) image)->type=type;
724 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
728 % I s O p a q u e I m a g e %
732 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
734 % IsOpaqueImage() returns MagickTrue if none of the pixels in the image have
735 % an opacity value other than opaque (0).
737 % The format of the IsOpaqueImage method is:
739 % MagickBooleanType IsOpaqueImage(const Image *image,
740 % ExceptionInfo *exception)
742 % A description of each parameter follows:
744 % o image: the image.
746 % o exception: return any errors or warnings in this structure.
749 MagickExport MagickBooleanType IsOpaqueImage(const Image *image,
750 ExceptionInfo *exception)
755 register const PixelPacket
765 Determine if image is opaque.
767 assert(image != (Image *) NULL);
768 assert(image->signature == MagickSignature);
769 if (image->debug != MagickFalse)
770 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
771 if (image->matte == MagickFalse)
773 image_view=AcquireCacheView(image);
774 for (y=0; y < (ssize_t) image->rows; y++)
776 p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
777 if (p == (const PixelPacket *) NULL)
779 for (x=0; x < (ssize_t) image->columns; x++)
781 if (GetOpacityPixelComponent(p) != OpaqueOpacity)
785 if (x < (ssize_t) image->columns)
788 image_view=DestroyCacheView(image_view);
789 return(y < (ssize_t) image->rows ? MagickFalse : MagickTrue);
793 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
797 % S e t I m a g e C h a n n e l D e p t h %
801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
803 % SetImageChannelDepth() sets the depth of the image.
805 % The format of the SetImageChannelDepth method is:
807 % MagickBooleanType SetImageDepth(Image *image,const size_t depth)
808 % MagickBooleanType SetImageChannelDepth(Image *image,
809 % const ChannelType channel,const size_t depth)
811 % A description of each parameter follows:
813 % o image: the image.
815 % o channel: the channel.
817 % o depth: the image depth.
820 MagickExport MagickBooleanType SetImageDepth(Image *image,
823 return(SetImageChannelDepth(image,CompositeChannels,depth));
826 MagickExport MagickBooleanType SetImageChannelDepth(Image *image,
827 const ChannelType channel,const size_t depth)
844 assert(image != (Image *) NULL);
845 if (image->debug != MagickFalse)
846 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
847 assert(image->signature == MagickSignature);
848 if (GetImageDepth(image,&image->exception) <= (size_t)
849 MagickMin((double) depth,(double) MAGICKCORE_QUANTUM_DEPTH))
855 Scale pixels to desired depth.
858 range=GetQuantumRange(depth);
859 exception=(&image->exception);
860 image_view=AcquireCacheView(image);
861 #if defined(MAGICKCORE_OPENMP_SUPPORT)
862 #pragma omp parallel for schedule(dynamic,4) shared(status)
864 for (y=0; y < (ssize_t) image->rows; y++)
875 if (status == MagickFalse)
877 q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
879 if (q == (PixelPacket *) NULL)
884 indexes=GetCacheViewAuthenticIndexQueue(image_view);
885 for (x=0; x < (ssize_t) image->columns; x++)
887 if ((channel & RedChannel) != 0)
888 SetRedPixelComponent(q,ScaleAnyToQuantum(ScaleQuantumToAny(
889 GetRedPixelComponent(q),range),range));
890 if ((channel & GreenChannel) != 0)
891 SetGreenPixelComponent(q,ScaleAnyToQuantum(ScaleQuantumToAny(
892 GetGreenPixelComponent(q),range),range));
893 if ((channel & BlueChannel) != 0)
894 SetBluePixelComponent(q,ScaleAnyToQuantum(ScaleQuantumToAny(
895 GetBluePixelComponent(q),range),range));
896 if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse))
897 SetOpacityPixelComponent(q,ScaleAnyToQuantum(ScaleQuantumToAny(
898 GetOpacityPixelComponent(q),range),range));
899 if (((channel & IndexChannel) != 0) &&
900 (image->colorspace == CMYKColorspace))
901 SetIndexPixelComponent(indexes+x,ScaleAnyToQuantum(ScaleQuantumToAny(
902 GetIndexPixelComponent(indexes+x),range),range));
905 if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
911 image_view=DestroyCacheView(image_view);
912 if (image->storage_class == PseudoClass)
921 #if defined(MAGICKCORE_OPENMP_SUPPORT)
922 #pragma omp parallel for schedule(dynamic,4) shared(status)
924 for (i=0; i < (ssize_t) image->colors; i++)
926 if ((channel & RedChannel) != 0)
927 GetRedPixelComponent(p)=ScaleAnyToQuantum(ScaleQuantumToAny(GetRedPixelComponent(p),range),range);
928 if ((channel & GreenChannel) != 0)
929 GetGreenPixelComponent(p)=ScaleAnyToQuantum(ScaleQuantumToAny(GetGreenPixelComponent(p),range),range);
930 if ((channel & BlueChannel) != 0)
931 GetBluePixelComponent(p)=ScaleAnyToQuantum(ScaleQuantumToAny(GetBluePixelComponent(p),range),range);
932 if ((channel & OpacityChannel) != 0)
933 GetOpacityPixelComponent(p)=ScaleAnyToQuantum(ScaleQuantumToAny(GetOpacityPixelComponent(p),range),