Remove metadata from an image using jmagick

905 Views Asked by At

I have removed the metadata from an image using the below imagemagick command.

convert input.png -strip output.png

It almost reduces 20% of the size for the 2MB file.

I need to do the same using Jmagick java api.

Is there any api available in Jmagick to remove the metadata?

2

There are 2 best solutions below

0
Mark Setchell On

I can't read Java, but there seems to be a strip method in src/magick/magick_MagickImage.c:

/*
 * Class:     magick_MagickImage
 * Method:    strip
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_magick_MagickImage_strip
    (JNIEnv *env, jobject self) {
    Image *image = NULL;
    jboolean retVal;

    image = (Image*) getHandle(env, self, "magickImageHandle", NULL);
    if (image == NULL) {
    throwMagickException(env, "Unable to retrieve image handle");
    return JNI_FALSE;
    }

    retVal = StripImage(image);
    return(retVal);
}
0
ltlBeBoy On

It depends on the version you are using!

JMagick up to version 6.7.7:

MagickImage has no method strip()

Current (Master) JMagick version:

MagickImage has a method named strip()