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