How to convert image to jp2 with MagickCore ?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Wim

How to convert image to jp2 with MagickCore ?

Post by Wim »

Hello,

I'm asking your help for a problem that i cannot solve.

I've made a program with MagickWand and it works perfectly but he takes too long to execute.
This program was made in order to calculate some textures composed by some images and convert it into jpg, png or jp2.

I rewrote it using MagickCore instead of MagickWand for a quicker result and it works perfectly for jpg and png but when it converts into jp2, it returns a kind of 8 colors images.

Here is the code :

Code: Select all

void            modify_img(t_list *params, t_final_img *output)
{
  size_t                        size;
  unsigned char                 *blob;
  MagickPixelPacket             background;
  ImageInfo                     *image_info;
  ExceptionInfo                 *exception;

  memset(&background, 0, sizeof(MagickPixelPacket));
  size = 0;
  image_info = AcquireImageInfo();
  exception = AcquireExceptionInfo();
  strcpy(image_info->filename, "dummy.");
  strcat(image_info->filename, output->extend);
  image_info->quality = output->quality;
  output->image = NewMagickImage(image_info, 512, 512, &background);
  calc_pixel(params, output);
  write_header_http(output);
  blob = ImageToBlob(image_info, output->image, &size, exception);
  if (exception->severity != UndefinedException)
    CatchException(exception);
  fwrite(blob, size, 1, stdout);
  fflush(stdout);
  if (cache_activated)
    writeInCache(blob, output, size);
  blob = xfree(blob);
  DestroyImageInfo(image_info);
  DestroyExceptionInfo(exception);
  DestroyImage(output->image);
}
Here is an example :
PNG :
Image
JP2 : (converted in jpg for upload but the render is the same)
Image

I'm on Linux and I've the lastest version of MagickCore and MagickWand.

Does anyone have an idea of what is the problem ?

Thanks
Wim

Re: How to convert image to jp2 with MagickCore ?

Post by Wim »

No one can help me ? :(
Post Reply