This source file includes following definitions.
- RegisterTHUMBNAILImage
- UnregisterTHUMBNAILImage
- WriteTHUMBNAILImage
#include "magick/studio.h"
#include "magick/attribute.h"
#include "magick/blob.h"
#include "magick/blob-private.h"
#include "magick/constitute.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/magick.h"
#include "magick/memory_.h"
#include "magick/module.h"
#include "magick/monitor.h"
#include "magick/monitor-private.h"
#include "magick/pixel-accessor.h"
#include "magick/profile.h"
#include "magick/property.h"
#include "magick/quantum-private.h"
#include "magick/static.h"
#include "magick/string_.h"
#include "magick/string-private.h"
static MagickBooleanType
WriteTHUMBNAILImage(const ImageInfo *,Image *);
ModuleExport size_t RegisterTHUMBNAILImage(void)
{
MagickInfo
*entry;
entry=SetMagickInfo("THUMBNAIL");
entry->encoder=(EncodeImageHandler *) WriteTHUMBNAILImage;
entry->description=ConstantString("EXIF Profile Thumbnail");
entry->module=ConstantString("THUMBNAIL");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
ModuleExport void UnregisterTHUMBNAILImage(void)
{
(void) UnregisterMagickInfo("THUMBNAIL");
}
static MagickBooleanType WriteTHUMBNAILImage(const ImageInfo *image_info,
Image *image)
{
const char
*property;
const StringInfo
*profile;
Image
*thumbnail_image;
ImageInfo
*write_info;
MagickBooleanType
status;
register ssize_t
i;
size_t
length;
ssize_t
offset;
unsigned char
magick[MaxTextExtent];
profile=GetImageProfile(image,"exif");
if (profile == (const StringInfo *) NULL)
ThrowWriterException(CoderError,"ImageDoesNotHaveAThumbnail");
property=GetImageProperty(image,"exif:JPEGInterchangeFormat");
if (property == (const char *) NULL)
ThrowWriterException(CoderError,"ImageDoesNotHaveAThumbnail");
offset=(ssize_t) StringToLong(property);
property=GetImageProperty(image,"exif:JPEGInterchangeFormatLength");
if (property == (const char *) NULL)
ThrowWriterException(CoderError,"ImageDoesNotHaveAThumbnail");
length=(size_t) StringToLong(property);
(void) ResetMagickMemory(magick,0,sizeof(magick));
for (i=0; i < (ssize_t) length; i++)
{
magick[0]=magick[1];
magick[1]=magick[2];
magick[2]=GetStringInfoDatum(profile)[offset+i];
if (memcmp(magick,"\377\330\377",3) == 0)
break;
}
thumbnail_image=BlobToImage(image_info,GetStringInfoDatum(profile)+offset+i-2,
length,&image->exception);
if (thumbnail_image == (Image *) NULL)
return(MagickFalse);
(void) SetImageType(thumbnail_image,thumbnail_image->matte == MagickFalse ?
TrueColorType : TrueColorMatteType);
(void) CopyMagickString(thumbnail_image->filename,image->filename,
MaxTextExtent);
write_info=CloneImageInfo(image_info);
(void) SetImageInfo(write_info,1,&image->exception);
*write_info->magick='\0';
if (LocaleCompare(write_info->magick,"THUMBNAIL") == 0)
(void) FormatLocaleString(thumbnail_image->filename,MaxTextExtent,
"miff:%s",write_info->filename);
status=WriteImage(write_info,thumbnail_image);
thumbnail_image=DestroyImage(thumbnail_image);
write_info=DestroyImageInfo(write_info);
return(status);
}