Magick++ strip exif

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
michmix

Magick++ strip exif

Post by michmix »

I want to remove EXIF from JPEG (or another) image in my c++ program (like convert -strip in command line).
For test version I use BMP buffer image, then save as JPEG again. And I have not found another way
mika

Re: Magick++ strip exif

Post by mika »

Hi!

I'd be interested in that as well, did you manage that?

(i tried using MagickCore::ThumbnailImage but it looks as though i can not manage the proper convert between Magick::Image and MagickCore::Image:

Code: Select all

int main(int argc,char **argv)
{
  MagickCore::ExceptionInfo
    exception;

  MagickCore::Image
    *image,
    *images,
    *resize_image,
    *thumbnails;

  MagickCore::ImageInfo
    *image_info;
thumbnails=MagickCore::NewImageList();

  Magick::Image image_m;
  try{image_m.read(argv[1]);}catch(...) {return 1;}
  images=image_m.image();

  while ((image=ShiftImageList(&images)) != (MagickCore::Image *) NULL)
  {
     resize_image=MagickCore::ThumbnailImage(image,150,150,&exception); // EXECUTION ERROR HERE: magick/resize.c:3271: main: Assertion `exception->signature == 0xabacadabUL' failed.
    if (resize_image == (MagickCore::Image *) NULL)
       MagickCore::MagickError(exception.severity,exception.reason,exception.description);
    (void) MagickCore::PushImageList(&thumbnails,resize_image,&exception);
    MagickCore::DestroyImage(image);
    MagickCore::DestroyImage(resize_image);
  }

  (void) strcpy(thumbnails->filename,"image.png");
  MagickCore::WriteImage(image_info,thumbnails);
  MagickCore::DestroyImageList(thumbnails);
  MagickCore::DestroyImageInfo(image_info);
  MagickCore::DestroyExceptionInfo(&exception);
  MagickCore::DestroyMagick();
  return(0);
}
)

Thx!

Mika.
mika

Re: Magick++ strip exif

Post by mika »

Answering myself:

Code: Select all

MagickCore::StripImage(image_.image());
does that very well. Although it strips all profiles, to strip specifically exif profiles, the profile function should be prefered.
Post Reply