]> granicus.if.org Git - imagemagick/blob - coders/txt.c
(no commit message)
[imagemagick] / coders / txt.c
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %                                                                             %
4 %                                                                             %
5 %                                                                             %
6 %                            TTTTT  X   X  TTTTT                              %
7 %                              T     X X     T                                %
8 %                              T      X      T                                %
9 %                              T     X X     T                                %
10 %                              T    X   X    T                                %
11 %                                                                             %
12 %                                                                             %
13 %                      Render Text Onto A Canvas Image.                       %
14 %                                                                             %
15 %                              Software Design                                %
16 %                                John Cristy                                  %
17 %                                 July 1992                                   %
18 %                                                                             %
19 %                                                                             %
20 %  Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization      %
21 %  dedicated to making software imaging solutions freely available.           %
22 %                                                                             %
23 %  You may not use this file except in compliance with the License.  You may  %
24 %  obtain a copy of the License at                                            %
25 %                                                                             %
26 %    http://www.imagemagick.org/script/license.php                            %
27 %                                                                             %
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.                                             %
33 %                                                                             %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %
37 */
38 \f
39 /*
40   Include declarations.
41 */
42 #include "magick/studio.h"
43 #include "magick/annotate.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/color.h"
49 #include "magick/color-private.h"
50 #include "magick/colorspace.h"
51 #include "magick/constitute.h"
52 #include "magick/draw.h"
53 #include "magick/exception.h"
54 #include "magick/exception-private.h"
55 #include "magick/geometry.h"
56 #include "magick/image.h"
57 #include "magick/image-private.h"
58 #include "magick/list.h"
59 #include "magick/magick.h"
60 #include "magick/memory_.h"
61 #include "magick/monitor.h"
62 #include "magick/monitor-private.h"
63 #include "magick/option.h"
64 #include "magick/pixel-private.h"
65 #include "magick/quantum-private.h"
66 #include "magick/static.h"
67 #include "magick/statistic.h"
68 #include "magick/string_.h"
69 #include "magick/module.h"
70 \f
71 /*
72   Forward declarations.
73 */
74 static MagickBooleanType
75   WriteTXTImage(const ImageInfo *,Image *);
76 \f
77 /*
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 %                                                                             %
80 %                                                                             %
81 %                                                                             %
82 %   I s T X T                                                                 %
83 %                                                                             %
84 %                                                                             %
85 %                                                                             %
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87 %
88 %  IsTXT() returns MagickTrue if the image format type, identified by the magick
89 %  string, is TXT.
90 %
91 %  The format of the IsTXT method is:
92 %
93 %      MagickBooleanType IsTXT(const unsigned char *magick,const size_t length)
94 %
95 %  A description of each parameter follows:
96 %
97 %    o magick: compare image format pattern against these bytes.
98 %
99 %    o length: Specifies the length of the magick string.
100 %
101 */
102 static MagickBooleanType IsTXT(const unsigned char *magick,const size_t length)
103 {
104 #define MagickID  "# ImageMagick pixel enumeration:"
105
106   char
107     colorspace[MaxTextExtent];
108
109   ssize_t
110     count;
111
112   unsigned long
113     columns,
114     depth,
115     rows;
116
117   if (length < 40)
118     return(MagickFalse);
119   if (LocaleNCompare((const char *) magick,MagickID,strlen(MagickID)) != 0)
120     return(MagickFalse);
121   count=(ssize_t) sscanf((const char *) magick+32,"%lu,%lu,%lu,%s",&columns,
122     &rows,&depth,colorspace);
123   if (count != 4)
124     return(MagickFalse);
125   return(MagickTrue);
126 }
127 \f
128 /*
129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130 %                                                                             %
131 %                                                                             %
132 %                                                                             %
133 %   R e a d T E X T I m a g e                                                 %
134 %                                                                             %
135 %                                                                             %
136 %                                                                             %
137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 %
139 %  ReadTEXTImage() reads a text file and returns it as an image.  It
140 %  allocates the memory necessary for the new Image structure and returns a
141 %  pointer to the new image.
142 %
143 %  The format of the ReadTEXTImage method is:
144 %
145 %      Image *ReadTEXTImage(const ImageInfo *image_info,Image *image,
146 %        char *text,ExceptionInfo *exception)
147 %
148 %  A description of each parameter follows:
149 %
150 %    o image_info: the image info.
151 %
152 %    o image: the image.
153 %
154 %    o text: the text storage buffer.
155 %
156 %    o exception: return any errors or warnings in this structure.
157 %
158 */
159 static Image *ReadTEXTImage(const ImageInfo *image_info,Image *image,
160   char *text,ExceptionInfo *exception)
161 {
162   char
163     filename[MaxTextExtent],
164     geometry[MaxTextExtent],
165     *p;
166
167   DrawInfo
168     *draw_info;
169
170   Image
171     *texture;
172
173   long
174     offset;
175
176   MagickBooleanType
177     status;
178
179   PointInfo
180     delta;
181
182   RectangleInfo
183     page;
184
185   TypeMetric
186     metrics;
187
188   /*
189     Open image file.
190   */
191   assert(image_info != (const ImageInfo *) NULL);
192   assert(image_info->signature == MagickSignature);
193   if (image_info->debug != MagickFalse)
194     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
195       image_info->filename);
196   assert(exception != (ExceptionInfo *) NULL);
197   assert(exception->signature == MagickSignature);
198   /*
199     Set the page geometry.
200   */
201   delta.x=DefaultResolution;
202   delta.y=DefaultResolution;
203   if ((image->x_resolution == 0.0) || (image->y_resolution == 0.0))
204     {
205       GeometryInfo
206         geometry_info;
207
208       MagickStatusType
209         flags;
210
211       flags=ParseGeometry(PSDensityGeometry,&geometry_info);
212       image->x_resolution=geometry_info.rho;
213       image->y_resolution=geometry_info.sigma;
214       if ((flags & SigmaValue) == 0)
215         image->y_resolution=image->x_resolution;
216     }
217   page.width=612;
218   page.height=792;
219   page.x=43;
220   page.y=43;
221   if (image_info->page != (char *) NULL)
222     (void) ParseAbsoluteGeometry(image_info->page,&page);
223   /*
224     Initialize Image structure.
225   */
226   image->columns=(unsigned long) floor(((page.width*image->x_resolution)/
227     delta.x)+0.5);
228   image->rows=(unsigned long) floor(((page.height*image->y_resolution)/
229     delta.y)+0.5);
230   image->page.x=0;
231   image->page.y=0;
232   texture=(Image *) NULL;
233   if (image_info->texture != (char *) NULL)
234     {
235       ImageInfo
236         *read_info;
237
238       read_info=CloneImageInfo(image_info);
239       SetImageInfoBlob(read_info,(void *) NULL,0);
240       (void) CopyMagickString(read_info->filename,image_info->texture,
241         MaxTextExtent);
242       texture=ReadImage(read_info,exception);
243       read_info=DestroyImageInfo(read_info);
244     }
245   /*
246     Annotate the text image.
247   */
248   (void) SetImageBackgroundColor(image);
249   draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
250   (void) CloneString(&draw_info->text,image_info->filename);
251   (void) FormatMagickString(geometry,MaxTextExtent,"0x0%+ld%+ld",page.x,page.y);
252   (void) CloneString(&draw_info->geometry,geometry);
253   status=GetTypeMetrics(image,draw_info,&metrics);
254   if (status == MagickFalse)
255     ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
256   page.y=(long) ceil(page.y+metrics.ascent-0.5);
257   (void) FormatMagickString(geometry,MaxTextExtent,"0x0%+ld%+ld",page.x,page.y);
258   (void) CloneString(&draw_info->geometry,geometry);
259   (void) CopyMagickString(filename,image_info->filename,MaxTextExtent);
260   if (*draw_info->text != '\0')
261     *draw_info->text='\0';
262   p=text;
263   for (offset=2*page.y; p != (char *) NULL; )
264   {
265     /*
266       Annotate image with text.
267     */
268     (void) ConcatenateString(&draw_info->text,text);
269     (void) ConcatenateString(&draw_info->text,"\n");
270     offset+=(long) (metrics.ascent-metrics.descent);
271     if (image->previous == (Image *) NULL)
272       {
273         status=SetImageProgress(image,LoadImageTag,offset,image->rows);
274         if (status == MagickFalse)
275           break;
276       }
277     p=ReadBlobString(image,text);
278     if ((offset < (long) image->rows) && (p != (char *) NULL))
279       continue;
280     if (texture != (Image *) NULL)
281       {
282         MagickProgressMonitor
283           progress_monitor;
284
285         progress_monitor=SetImageProgressMonitor(image,
286           (MagickProgressMonitor) NULL,image->client_data);
287         (void) TextureImage(image,texture);
288         (void) SetImageProgressMonitor(image,progress_monitor,
289           image->client_data);
290       }
291     (void) AnnotateImage(image,draw_info);
292     if (p == (char *) NULL)
293       break;
294     /*
295       Page is full-- allocate next image structure.
296     */
297     *draw_info->text='\0';
298     offset=2*page.y;
299     AcquireNextImage(image_info,image);
300     if (GetNextImageInList(image) == (Image *) NULL)
301       {
302         image=DestroyImageList(image);
303         return((Image *) NULL);
304       }
305     image->next->columns=image->columns;
306     image->next->rows=image->rows;
307     image=SyncNextImageInList(image);
308     (void) CopyMagickString(image->filename,filename,MaxTextExtent);
309     (void) SetImageBackgroundColor(image);
310     status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
311       GetBlobSize(image));
312     if (status == MagickFalse)
313       break;
314   }
315   if (texture != (Image *) NULL)
316     {
317       MagickProgressMonitor
318         progress_monitor;
319
320       progress_monitor=SetImageProgressMonitor(image,
321         (MagickProgressMonitor) NULL,image->client_data);
322       (void) TextureImage(image,texture);
323       (void) SetImageProgressMonitor(image,progress_monitor,image->client_data);
324     }
325   (void) AnnotateImage(image,draw_info);
326   if (texture != (Image *) NULL)
327     texture=DestroyImage(texture);
328   draw_info=DestroyDrawInfo(draw_info);
329   (void) CloseBlob(image);
330   return(GetFirstImageInList(image));
331 }
332 \f
333 /*
334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
335 %                                                                             %
336 %                                                                             %
337 %                                                                             %
338 %   R e a d T X T I m a g e                                                   %
339 %                                                                             %
340 %                                                                             %
341 %                                                                             %
342 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
343 %
344 %  ReadTXTImage() reads a text file and returns it as an image.  It allocates
345 %  the memory necessary for the new Image structure and returns a pointer to
346 %  the new image.
347 %
348 %  The format of the ReadTXTImage method is:
349 %
350 %      Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
351 %
352 %  A description of each parameter follows:
353 %
354 %    o image_info: the image info.
355 %
356 %    o exception: return any errors or warnings in this structure.
357 %
358 */
359 static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
360 {
361   char
362     colorspace[MaxTextExtent],
363     text[MaxTextExtent];
364
365   Image
366     *image;
367
368   IndexPacket
369     *indexes;
370
371   long
372     type,
373     x,
374     y;
375
376   LongPixelPacket
377     pixel;
378
379   MagickBooleanType
380     status;
381
382   QuantumAny
383     range;
384
385   register long
386     i;
387
388   register PixelPacket
389     *q;
390
391   ssize_t
392     count;
393
394   unsigned long
395     depth,
396     max_value;
397
398   /*
399     Open image file.
400   */
401   assert(image_info != (const ImageInfo *) NULL);
402   assert(image_info->signature == MagickSignature);
403   if (image_info->debug != MagickFalse)
404     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
405       image_info->filename);
406   assert(exception != (ExceptionInfo *) NULL);
407   assert(exception->signature == MagickSignature);
408   image=AcquireImage(image_info);
409   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
410   if (status == MagickFalse)
411     {
412       image=DestroyImageList(image);
413       return((Image *) NULL);
414     }
415   (void) ResetMagickMemory(text,0,sizeof(text));
416   (void) ReadBlobString(image,text);
417   if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) != 0)
418     return(ReadTEXTImage(image_info,image,text,exception));
419   *colorspace='\0';
420   count=(ssize_t) sscanf(text+32,"%lu,%lu,%lu,%s",&image->columns,
421     &image->rows,&max_value,colorspace);
422   if (count != 4)
423     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
424   for (depth=1; (GetQuantumRange(depth)+1) < max_value; depth++) ;
425   image->depth=depth;
426   LocaleLower(colorspace);
427   i=(long) strlen(colorspace)-1;
428   image->matte=MagickFalse;
429   if ((i > 0) && (colorspace[i] == 'a'))
430     {
431       colorspace[i]='\0';
432       image->matte=MagickTrue;
433     }
434   type=ParseMagickOption(MagickColorspaceOptions,MagickFalse,colorspace);
435   if (type < 0)
436     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
437   image->colorspace=(ColorspaceType) type;
438   (void) ResetMagickMemory(&pixel,0,sizeof(pixel));
439   (void) SetImageBackgroundColor(image);
440   range=GetQuantumRange(image->depth);
441   while (ReadBlobString(image,text) != (char *) NULL)
442   {
443     if (image->colorspace == CMYKColorspace)
444       {
445         if (image->matte != MagickFalse)
446           count=(ssize_t) sscanf(text,"%ld,%ld: (%lu,%lu,%lu,%lu,%lu",&x,&y,
447             &pixel.red,&pixel.green,&pixel.blue,&pixel.index,&pixel.opacity);
448         else
449           count=(ssize_t) sscanf(text,"%ld,%ld: (%lu,%lu,%lu,%lu",&x,&y,
450             &pixel.red,&pixel.green,&pixel.blue,&pixel.index);
451       }
452     else
453       if (image->matte != MagickFalse)
454         count=(ssize_t) sscanf(text,"%ld,%ld: (%lu,%lu,%lu,%lu",&x,&y,
455           &pixel.red,&pixel.green,&pixel.blue,&pixel.opacity);
456       else
457         count=(ssize_t) sscanf(text,"%ld,%ld: (%lu,%lu,%lu",&x,&y,
458           &pixel.red,&pixel.green,&pixel.blue);
459     if (count < 5)
460       continue;
461     q=GetAuthenticPixels(image,x,y,1,1,exception);
462     if (q == (PixelPacket *) NULL)
463       continue;
464     q->red=ScaleAnyToQuantum(pixel.red,range);
465     q->green=ScaleAnyToQuantum(pixel.green,range);
466     q->blue=ScaleAnyToQuantum(pixel.blue,range);
467     if (image->colorspace == CMYKColorspace)
468       {
469         indexes=GetAuthenticIndexQueue(image);
470         *indexes=ScaleAnyToQuantum(pixel.index,range);
471       }
472     if (image->matte != MagickFalse)
473       q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel.opacity,
474         range));
475     if (SyncAuthenticPixels(image,exception) == MagickFalse)
476       break;
477   }
478   return(GetFirstImageInList(image));
479 }
480 \f
481 /*
482 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
483 %                                                                             %
484 %                                                                             %
485 %                                                                             %
486 %   R e g i s t e r T X T I m a g e                                           %
487 %                                                                             %
488 %                                                                             %
489 %                                                                             %
490 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
491 %
492 %  RegisterTXTImage() adds attributes for the TXT image format to the
493 %  list of supported formats.  The attributes include the image format
494 %  tag, a method to read and/or write the format, whether the format
495 %  supports the saving of more than one frame to the same file or blob,
496 %  whether the format supports native in-memory I/O, and a brief
497 %  description of the format.
498 %
499 %  The format of the RegisterTXTImage method is:
500 %
501 %      unsigned long RegisterTXTImage(void)
502 %
503 */
504 ModuleExport unsigned long RegisterTXTImage(void)
505 {
506   MagickInfo
507     *entry;
508
509   entry=SetMagickInfo("TEXT");
510   entry->decoder=(DecodeImageHandler *) ReadTXTImage;
511   entry->encoder=(EncodeImageHandler *) WriteTXTImage;
512   entry->raw=MagickTrue;
513   entry->adjoin=MagickFalse;
514   entry->endian_support=MagickTrue;
515   entry->description=ConstantString("Text");
516   entry->module=ConstantString("TXT");
517   (void) RegisterMagickInfo(entry);
518   entry=SetMagickInfo("TXT");
519   entry->decoder=(DecodeImageHandler *) ReadTXTImage;
520   entry->encoder=(EncodeImageHandler *) WriteTXTImage;
521   entry->adjoin=MagickFalse;
522   entry->description=ConstantString("Text");
523   entry->magick=(IsImageFormatHandler *) IsTXT;
524   entry->module=ConstantString("TXT");
525   (void) RegisterMagickInfo(entry);
526   return(MagickImageCoderSignature);
527 }
528 \f
529 /*
530 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
531 %                                                                             %
532 %                                                                             %
533 %                                                                             %
534 %   U n r e g i s t e r T X T I m a g e                                       %
535 %                                                                             %
536 %                                                                             %
537 %                                                                             %
538 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
539 %
540 %  UnregisterTXTImage() removes format registrations made by the
541 %  TXT module from the list of supported format.
542 %
543 %  The format of the UnregisterTXTImage method is:
544 %
545 %      UnregisterTXTImage(void)
546 %
547 */
548 ModuleExport void UnregisterTXTImage(void)
549 {
550   (void) UnregisterMagickInfo("TEXT");
551   (void) UnregisterMagickInfo("TXT");
552 }
553 \f
554 /*
555 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
556 %                                                                             %
557 %                                                                             %
558 %                                                                             %
559 %   W r i t e T X T I m a g e                                                 %
560 %                                                                             %
561 %                                                                             %
562 %                                                                             %
563 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564 %
565 %  WriteTXTImage writes the pixel values as text numbers.
566 %
567 %  The format of the WriteTXTImage method is:
568 %
569 %      MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image)
570 %
571 %  A description of each parameter follows.
572 %
573 %    o image_info: the image info.
574 %
575 %    o image:  The image.
576 %
577 */
578 static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image)
579 {
580   char
581     buffer[MaxTextExtent],
582     colorspace[MaxTextExtent],
583     tuple[MaxTextExtent];
584
585   long
586     y;
587
588   MagickBooleanType
589     status;
590
591   MagickPixelPacket
592     pixel;
593
594   register const IndexPacket
595     *indexes;
596
597   register const PixelPacket
598     *p;
599
600   register long
601     x;
602
603   /*
604     Open output image file.
605   */
606   assert(image_info != (const ImageInfo *) NULL);
607   assert(image_info->signature == MagickSignature);
608   assert(image != (Image *) NULL);
609   assert(image->signature == MagickSignature);
610   if (image->debug != MagickFalse)
611     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
612   status=OpenBlob(image_info,image,WriteBlobMode,&image->exception);
613   if (status == MagickFalse)
614     return(status);
615   (void) CopyMagickString(colorspace,MagickOptionToMnemonic(
616     MagickColorspaceOptions,(long) image->colorspace),MaxTextExtent);
617   LocaleLower(colorspace);
618   image->depth=GetImageQuantumDepth(image,MagickTrue);
619   if (image->matte != MagickFalse)
620     (void) ConcatenateMagickString(colorspace,"a",MaxTextExtent);
621   (void) FormatMagickString(buffer,MaxTextExtent,
622     "# ImageMagick pixel enumeration: %lu,%lu,%lu,%s\n",image->columns,
623     image->rows,(unsigned long) GetQuantumRange(image->depth),colorspace);
624   (void) WriteBlobString(image,buffer);
625   GetMagickPixelPacket(image,&pixel);
626   for (y=0; y < (long) image->rows; y++)
627   {
628     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
629     if (p == (const PixelPacket *) NULL)
630       break;
631     indexes=GetVirtualIndexQueue(image);
632     for (x=0; x < (long) image->columns; x++)
633     {
634       (void) FormatMagickString(buffer,MaxTextExtent,"%ld,%ld: ",x,y);
635       (void) WriteBlobString(image,buffer);
636       SetMagickPixelPacket(image,p,indexes+x,&pixel);
637       (void) CopyMagickString(tuple,"(",MaxTextExtent);
638       ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple);
639       (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
640       ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple);
641       (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
642       ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple);
643       if (pixel.colorspace == CMYKColorspace)
644         {
645           (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
646           ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance,tuple);
647         }
648       if (pixel.matte != MagickFalse)
649         {
650           (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
651           ConcatenateColorComponent(&pixel,AlphaChannel,X11Compliance,tuple);
652         }
653       (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
654       (void) WriteBlobString(image,tuple);
655       (void) WriteBlobString(image,"  ");
656       GetColorTuple(&pixel,MagickTrue,tuple);
657       (void) FormatMagickString(buffer,MaxTextExtent,"%s",tuple);
658       (void) WriteBlobString(image,buffer);
659       (void) WriteBlobString(image,"  ");
660       (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
661         &image->exception);
662       (void) WriteBlobString(image,tuple);
663       (void) WriteBlobString(image,"\n");
664       p++;
665     }
666     status=SetImageProgress(image,SaveImageTag,y,image->rows);
667     if (status == MagickFalse)
668       break;
669   }
670   (void) CloseBlob(image);
671   return(MagickTrue);
672 }