Image format conversion API

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
sap_14feb

Image format conversion API

Post by sap_14feb »

Hi
I am trying to apply multiple resize operation on image uploaded through web page.
I have a JPG image uploaded from a web page in my memory blob.
Before performing multiple resize operations on the image i want to convert the JPG to MPC and then want to create new resized jpg images from the MPC image.

But i am having very hard time to convert the image from .jpg to .mpc using c or c++ API.
It is the most basic operation of the convert command in IM.

Is there any API that can be used to perform the basic conversion operation?

Thanks
Shalin.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Image format conversion API

Post by anthony »

Still having problems?

convert t.jpg t.mpc

Works for me, note that "t.mpc" also creates a "t.cache" file which does with it.
The file is also only usable on the machine that created it as it is OS and archeteture dependant, but is also an instant read as it is a direct memory type access.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
sap_14feb

Re: Image format conversion API

Post by sap_14feb »

Hi Anthony,
Thanks for your reply. I can use conversion using command line utility provided.
But i am using the software in a web application and have to use conversion using C or C++ API of core imagemagick code. So, please let me know if you have any idea on how to convert image using any imagemagick API.

Thanks
Shalin.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Image format conversion API

Post by el_supremo »

Here's a function in C which uses MagickWand to do the conversion:

Code: Select all

#include <windows.h>
#include <wand/magick_wand.h>

void test_wand(void)
{
	MagickWand *m_wand = NULL;

	MagickWandGenesis();

	/* Create a wand */
	m_wand = NewMagickWand();
	/* Read the input image */
	if(!MagickReadImage(m_wand,"t.jpg")) {
		MessageBox(NULL,"Failed to read input file","",MB_OK);
	} else {
		/* and write it in a different format */
		MagickWriteImage(m_wand,"t.mpc");
	}
	/* Tidy up */
	m_wand = DestroyMagickWand(m_wand);
	MagickWandTerminus();
}
Pete
Post Reply