Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jpeg images don't support property writing? #124

Open
Danack opened this issue Nov 16, 2015 · 2 comments

Comments

@Danack
Copy link
Collaborator

commented Nov 16, 2015

The below should work, right?

$formats = [
    'jpg',
    'png'
];

foreach ($formats as $format) {
    $im = new Imagick();
    $im->newimage(50, 50, 'blue');
    $im->setimageformat($format);
    $im->setImageProperty('Exif:Make', 'a property');
    $im->writeimage('./output.'.$format);
    $im->destroy();
    $im2 = new Imagick('./output.'.$format);
    printf("Format %s *****\n", $format);
    printf("Property value %s\n", var_export($im2->getImageProperty('Exif:Make'), true));

    $im2->destroy();
}
Format jpg *****
Property value false
Format png *****
Property value 'a property'
@Danack

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 17, 2015

For Jpeg, the only property that is persisted is one named 'comment'.

$propertyNames = [
    "comment",
    "anything_else"
];

$formats = [
    'jpg',
    'png'
];

foreach ($formats as $format) {
    foreach ($propertyNames as $propertyName) {
        $imagick = new Imagick('./LittleRobin.jpg');
        $imagick->setImageProperty($propertyName, "Modified value");
        $imagick->setFormat($format);
        $imagick->writeImage("./testModified.".$format);
        $imagick2 = new Imagick("./testModified.".$format);
        printf(
            "After reloading '%s' property '%s' is:%s\n",
            $format,
            $propertyName,
            var_export($imagick2->getImageProperty($propertyName), true)
        );
    }
}

@Danack Danack added the Documentation label Dec 5, 2015

@Danack

This comment has been minimized.

Copy link
Collaborator Author

commented Jun 18, 2016

To summarise:

  • Jpegs only support writing comments
  • Exif information is never updated.

Those two bits of info need to be added to http://php.net/manual/en/imagick.setimageproperty.php

Source of info: ImageMagick/ImageMagick#55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.