Skip to content

Jpeg images don't support property writing? #124

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

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

Jpeg images don't support property writing? #124

Danack opened this issue Nov 16, 2015 · 2 comments

Comments

@Danack
Copy link
Collaborator

Danack 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
Copy link
Collaborator Author

Danack 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
Copy link
Collaborator Author

Danack 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
Development

No branches or pull requests

1 participant