]> 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/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) (((page.width*image->x_resolution)/
227     delta.x)+0.5);
228   image->rows=(unsigned long) (((page.height*image->y_resolution)/delta.y)+0.5);
229   image->page.x=0;
230   image->page.y=0;
231   texture=(Image *) NULL;
232   if (image_info->texture != (char *) NULL)
233     {
234       ImageInfo
235         *read_info;
236
237       read_info=CloneImageInfo(image_info);
238       SetImageInfoBlob(read_info,(void *) NULL,0);
239       (void) CopyMagickString(read_info->filename,image_info->texture,
240         MaxTextExtent);
241       texture=ReadImage(read_info,exception);
242       read_info=DestroyImageInfo(read_info);
243     }
244   /*
245     Annotate the text image.
246   */
247   (void) SetImageBackgroundColor(image);
248   draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
249   (void) CloneString(&draw_info->text,image_info->filename);
250   (void) FormatMagickString(geometry,MaxTextExtent,"0x0%+ld%+ld",page.x,page.y);
251   (void) CloneString(&draw_info->geometry,geometry);
252   status=GetTypeMetrics(image,draw_info,&metrics);
253   if (status == MagickFalse)
254     ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
255   page.y=(long) (page.y+metrics.ascent+0.5);
256   (void) FormatMagickString(geometry,MaxTextExtent,"0x0%+ld%+ld",page.x,page.y);
257   (void) CloneString(&draw_info->geometry,geometry);
258   (void) CopyMagickString(filename,image_info->filename,MaxTextExtent);
259   if (*draw_info->text != '\0')
260     *draw_info->text='\0';
261   p=text;
262   for (offset=2*page.y; p != (char *) NULL; )
263   {
264     /*
265       Annotate image with text.
266     */
267     (void) ConcatenateString(&draw_info->text,text);
268     (void) ConcatenateString(&draw_info->text,"\n");
269     offset+=(long) (metrics.ascent-metrics.descent);
270     if (image->previous == (Image *) NULL)
271       {
272         status=SetImageProgress(image,LoadImageTag,offset,image->rows);
273         if (status == MagickFalse)
274           break;
275       }
276     p=ReadBlobString(image,text);
277     if ((offset < (long) image->rows) && (p != (char *) NULL))
278       continue;
279     if (texture != (Image *) NULL)
280       {
281         MagickProgressMonitor
282           progress_monitor;
283
284         progress_monitor=SetImageProgressMonitor(image,
285           (MagickProgressMonitor) NULL,image->client_data);
286         (void) TextureImage(image,texture);
287         (void) SetImageProgressMonitor(image,progress_monitor,
288           image->client_data);
289       }
290     (void) AnnotateImage(image,draw_info);
291     if (p == (char *) NULL)
292       break;
293     /*
294       Page is full-- allocate next image structure.
295     */
296     *draw_info->text='\0';
297     offset=2*page.y;
298     AcquireNextImage(image_info,image);
299     if (GetNextImageInList(image) == (Image *) NULL)
300       {
301         image=DestroyImageList(image);
302         return((Image *) NULL);
303       }
304     image->next->columns=image->columns;
305     image->next->rows=image->rows;
306     image=SyncNextImageInList(image);
307     (void) CopyMagickString(image->filename,filename,MaxTextExtent);
308     (void) SetImageBackgroundColor(image);
309     status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
310       GetBlobSize(image));
311     if (status == MagickFalse)
312       break;
313   }
314   if (texture != (Image *) NULL)
315     {
316       MagickProgressMonitor
317         progress_monitor;
318
319       progress_monitor=SetImageProgressMonitor(image,
320         (MagickProgressMonitor) NULL,image->client_data);
321       (void) TextureImage(image,texture);
322       (void) SetImageProgressMonitor(image,progress_monitor,image->client_data);
323     }
324   (void) AnnotateImage(image,draw_info);
325   if (texture != (Image *) NULL)
326     texture=DestroyImage(texture);
327   draw_info=DestroyDrawInfo(draw_info);
328   (void) CloseBlob(image);
329   return(GetFirstImageInList(image));
330 }
331 \f
332 /*
333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
334 %                                                                             %
335 %                                                                             %
336 %                                                                             %
337 %   R e a d T X T I m a g e                                                   %
338 %                                                                             %
339 %                                                                             %
340 %                                                                             %
341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
342 %
343 %  ReadTXTImage() reads a text file and returns it as an image.  It allocates
344 %  the memory necessary for the new Image structure and returns a pointer to
345 %  the new image.
346 %
347 %  The format of the ReadTXTImage method is:
348 %
349 %      Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
350 %
351 %  A description of each parameter follows:
352 %
353 %    o image_info: the image info.
354 %
355 %    o exception: return any errors or warnings in this structure.
356 %
357 */
358 static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
359 {
360   char
361     colorspace[MaxTextExtent],
362     text[MaxTextExtent];
363
364   Image
365     *image;
366
367   IndexPacket
368     *indexes;
369
370   long
371     type,
372     x,
373     y;
374
375   LongPixelPacket
376     pixel;
377
378   MagickBooleanType
379     status;
380
381   QuantumAny
382     range;
383
384   register long
385     i;
386
387   register PixelPacket
388     *q;
389
390   ssize_t
391     count;
392
393   unsigned long
394     depth,
395     max_value;
396
397   /*
398     Open image file.
399   */
400   assert(image_info != (const ImageInfo *) NULL);
401   assert(image_info->signature == MagickSignature);
402   if (image_info->debug != MagickFalse)
403     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
404       image_info->filename);
405   assert(exception != (ExceptionInfo *) NULL);
406   assert(exception->signature == MagickSignature);
407   image=AcquireImage(image_info);
408   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
409   if (status == MagickFalse)
410     {
411       image=DestroyImageList(image);
412       return((Image *) NULL);
413     }
414   (void) ResetMagickMemory(text,0,sizeof(text));
415   (void) ReadBlobString(image,text);
416   if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) != 0)
417     return(ReadTEXTImage(image_info,image,text,exception));
418   *colorspace='\0';
419   count=(ssize_t) sscanf(text+32,"%lu,%lu,%lu,%s",&image->columns,
420     &image->rows,&max_value,colorspace);
421   if (count != 4)
422     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
423   for (depth=1; (GetQuantumRange(depth)+1) < max_value; depth++) ;
424   image->depth=depth;
425   LocaleLower(colorspace);
426   i=(long) strlen(colorspace)-1;
427   image->matte=MagickFalse;
428   if ((i > 0) && (colorspace[i] == 'a'))
429     {
430       colorspace[i]='\0';
431       image->matte=MagickTrue;
432     }
433   type=ParseMagickOption(MagickColorspaceOptions,MagickFalse,colorspace);
434   if (type < 0)
435     ThrowReaderException(CorruptImageError,"ImproperImageHeader");
436   image->colorspace=(ColorspaceType) type;
437   (void) ResetMagickMemory(&pixel,0,sizeof(pixel));
438   (void) SetImageBackgroundColor(image);
439   range=GetQuantumRange(image->depth);
440   while (ReadBlobString(image,text) != (char *) NULL)
441   {
442     if (image->colorspace == CMYKColorspace)
443       {
444         if (image->matte != MagickFalse)
445           count=(ssize_t) sscanf(text,"%ld,%ld: (%lu,%lu,%lu,%lu,%lu",&x,&y,
446             &pixel.red,&pixel.green,&pixel.blue,&pixel.index,&pixel.opacity);
447         else
448           count=(ssize_t) sscanf(text,"%ld,%ld: (%lu,%lu,%lu,%lu",&x,&y,
449             &pixel.red,&pixel.green,&pixel.blue,&pixel.index);
450       }
451     else
452       if (image->matte != MagickFalse)
453         count=(ssize_t) sscanf(text,"%ld,%ld: (%lu,%lu,%lu,%lu",&x,&y,
454           &pixel.red,&pixel.green,&pixel.blue,&pixel.opacity);
455       else
456         count=(ssize_t) sscanf(text,"%ld,%ld: (%lu,%lu,%lu",&x,&y,
457           &pixel.red,&pixel.green,&pixel.blue);
458     if (count < 5)
459       continue;
460     q=GetAuthenticPixels(image,x,y,1,1,exception);
461     if (q == (PixelPacket *) NULL)
462       continue;
463     q->red=ScaleAnyToQuantum(pixel.red,range);
464     q->green=ScaleAnyToQuantum(pixel.green,range);
465     q->blue=ScaleAnyToQuantum(pixel.blue,range);
466     if (image->colorspace == CMYKColorspace)
467       {
468         indexes=GetAuthenticIndexQueue(image);
469         *indexes=ScaleAnyToQuantum(pixel.index,range);
470       }
471     if (image->matte != MagickFalse)
472       q->opacity=(Quantum) (QuantumRange-ScaleAnyToQuantum(pixel.opacity,
473         range));
474     if (SyncAuthenticPixels(image,exception) == MagickFalse)
475       break;
476   }
477   return(GetFirstImageInList(image));
478 }
479 \f
480 /*
481 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
482 %                                                                             %
483 %                                                                             %
484 %                                                                             %
485 %   R e g i s t e r T X T I m a g e                                           %
486 %                                                                             %
487 %                                                                             %
488 %                                                                             %
489 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
490 %
491 %  RegisterTXTImage() adds attributes for the TXT image format to the
492 %  list of supported formats.  The attributes include the image format
493 %  tag, a method to read and/or write the format, whether the format
494 %  supports the saving of more than one frame to the same file or blob,
495 %  whether the format supports native in-memory I/O, and a brief
496 %  description of the format.
497 %
498 %  The format of the RegisterTXTImage method is:
499 %
500 %      unsigned long RegisterTXTImage(void)
501 %
502 */
503 ModuleExport unsigned long RegisterTXTImage(void)
504 {
505   MagickInfo
506     *entry;
507
508   entry=SetMagickInfo("TEXT");
509   entry->decoder=(DecodeImageHandler *) ReadTXTImage;
510   entry->encoder=(EncodeImageHandler *) WriteTXTImage;
511   entry->raw=MagickTrue;
512   entry->adjoin=MagickFalse;
513   entry->endian_support=MagickTrue;
514   entry->description=ConstantString("Text");
515   entry->module=ConstantString("TXT");
516   (void) RegisterMagickInfo(entry);
517   entry=SetMagickInfo("TXT");
518   entry->decoder=(DecodeImageHandler *) ReadTXTImage;
519   entry->encoder=(EncodeImageHandler *) WriteTXTImage;
520   entry->adjoin=MagickFalse;
521   entry->description=ConstantString("Text");
522   entry->magick=(IsImageFormatHandler *) IsTXT;
523   entry->module=ConstantString("TXT");
524   (void) RegisterMagickInfo(entry);
525   return(MagickImageCoderSignature);
526 }
527 \f
528 /*
529 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
530 %                                                                             %
531 %                                                                             %
532 %                                                                             %
533 %   U n r e g i s t e r T X T I m a g e                                       %
534 %                                                                             %
535 %                                                                             %
536 %                                                                             %
537 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
538 %
539 %  UnregisterTXTImage() removes format registrations made by the
540 %  TXT module from the list of supported format.
541 %
542 %  The format of the UnregisterTXTImage method is:
543 %
544 %      UnregisterTXTImage(void)
545 %
546 */
547 ModuleExport void UnregisterTXTImage(void)
548 {
549   (void) UnregisterMagickInfo("TEXT");
550   (void) UnregisterMagickInfo("TXT");
551 }
552 \f
553 /*
554 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
555 %                                                                             %
556 %                                                                             %
557 %                                                                             %
558 %   W r i t e T X T I m a g e                                                 %
559 %                                                                             %
560 %                                                                             %
561 %                                                                             %
562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
563 %
564 %  WriteTXTImage writes the pixel values as text numbers.
565 %
566 %  The format of the WriteTXTImage method is:
567 %
568 %      MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image)
569 %
570 %  A description of each parameter follows.
571 %
572 %    o image_info: the image info.
573 %
574 %    o image:  The image.
575 %
576 */
577 static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image)
578 {
579   char
580     buffer[MaxTextExtent],
581     colorspace[MaxTextExtent],
582     tuple[MaxTextExtent];
583
584   long
585     y;
586
587   MagickBooleanType
588     status;
589
590   MagickPixelPacket
591     pixel;
592
593   register const IndexPacket
594     *indexes;
595
596   register const PixelPacket
597     *p;
598
599   register long
600     x;
601
602   /*
603     Open output image file.
604   */
605   assert(image_info != (const ImageInfo *) NULL);
606   assert(image_info->signature == MagickSignature);
607   assert(image != (Image *) NULL);
608   assert(image->signature == MagickSignature);
609   if (image->debug != MagickFalse)
610     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
611   status=OpenBlob(image_info,image,WriteBlobMode,&image->exception);
612   if (status == MagickFalse)
613     return(status);
614   (void) CopyMagickString(colorspace,MagickOptionToMnemonic(
615     MagickColorspaceOptions,(long) image->colorspace),MaxTextExtent);
616   LocaleLower(colorspace);
617   image->depth=GetImageQuantumDepth(image,MagickTrue);
618   if (image->matte != MagickFalse)
619     (void) ConcatenateMagickString(colorspace,"a",MaxTextExtent);
620   (void) FormatMagickString(buffer,MaxTextExtent,
621     "# ImageMagick pixel enumeration: %lu,%lu,%lu,%s\n",image->columns,
622     image->rows,(unsigned long) GetQuantumRange(image->depth),colorspace);
623   (void) WriteBlobString(image,buffer);
624   GetMagickPixelPacket(image,&pixel);
625   for (y=0; y < (long) image->rows; y++)
626   {
627     p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
628     if (p == (const PixelPacket *) NULL)
629       break;
630     indexes=GetVirtualIndexQueue(image);
631     for (x=0; x < (long) image->columns; x++)
632     {
633       (void) FormatMagickString(buffer,MaxTextExtent,"%ld,%ld: ",x,y);
634       (void) WriteBlobString(image,buffer);
635       SetMagickPixelPacket(image,p,indexes+x,&pixel);
636       (void) CopyMagickString(tuple,"(",MaxTextExtent);
637       ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple);
638       (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
639       ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple);
640       (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
641       ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple);
642       if (pixel.colorspace == CMYKColorspace)
643         {
644           (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
645           ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance,tuple);
646         }
647       if (pixel.matte != MagickFalse)
648         {
649           (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
650           ConcatenateColorComponent(&pixel,AlphaChannel,X11Compliance,tuple);
651         }
652       (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
653       (void) WriteBlobString(image,tuple);
654       (void) WriteBlobString(image,"  ");
655       GetColorTuple(&pixel,MagickTrue,tuple);
656       (void) FormatMagickString(buffer,MaxTextExtent,"%s",tuple);
657       (void) WriteBlobString(image,buffer);
658       (void) WriteBlobString(image,"  ");
659       (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
660         &image->exception);
661       (void) WriteBlobString(image,tuple);
662       (void) WriteBlobString(image,"\n");
663       p++;
664     }
665     status=SetImageProgress(image,SaveImageTag,y,image->rows);
666     if (status == MagickFalse)
667       break;
668   }
669   (void) CloseBlob(image);
670   return(MagickTrue);
671 }