PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
-
garyash
- Posts: 5
- Joined: 2018-09-13T09:55:44-07:00
- Authentication code: 1152
Post
by garyash » 2018-09-13T10:11:06-07:00
I'm trying to use perlmagick to automate creating Apple TV icons and I'm having a problem generating an black png file and wondered if anyone could help
The resize fails.
Image Magick version: 7.0.8-11
Code: Select all
#!/usr/bin/env perl
use strict;
use warnings;
use Image::Magick;
my $image = Image::Magick->new(size => "1200x1200");
my $error = $image->Read('canvas:black');
if ("$error") {
errorMessage($error);
}
$error = $image->Resize(geometry => "800×480!");
if ("$error") {
errorMessage($error);
}
$image->Write(filename => "AppleTV-Home-Background\@2x.png", compression => "None");
#*****************************************************************************************
# print an error message and exit
#*****************************************************************************************
sub errorMessage {
print "@_\n";
exit(2);
}
-
fmw42
- Posts: 24481
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Post
by fmw42 » 2018-09-13T10:58:50-07:00
I am not a PerlMagic expert. But try xc:black rather than canvas:black
-
garyash
- Posts: 5
- Joined: 2018-09-13T09:55:44-07:00
- Authentication code: 1152
Post
by garyash » 2018-09-13T12:16:29-07:00
that didn't help. The problem seems to be the geometry
-
fmw42
- Posts: 24481
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Post
by fmw42 » 2018-09-13T12:24:19-07:00
Does it help to replace "800×480!" with "800×480\!"
Do you get any error messages? If so, what are they.
What is the size of the output?
Perhaps the \@ symbol in the output is not a good character. Try changing AppleTV-Home-Background\@2x.png to AppleTV-Home-Background_2x.png or something else without the \@
-
garyash
- Posts: 5
- Joined: 2018-09-13T09:55:44-07:00
- Authentication code: 1152
Post
by garyash » 2018-09-13T13:22:29-07:00
the error I'''m getting now is Exception 410: invalid geometry `800×480!' @ error/geometry.c/ParseRegionGeometry/1629
-
fmw42
- Posts: 24481
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Post
by fmw42 » 2018-09-13T13:50:43-07:00
Did you try replacing "800×480!" with "800×480\!"
Does it work if you just use "800×480" even though that is not what you want. I am trying to figure out if perhaps Perlmagick does not know about "!"
-
garyash
- Posts: 5
- Joined: 2018-09-13T09:55:44-07:00
- Authentication code: 1152
Post
by garyash » 2018-09-13T14:20:21-07:00
Yes I did use the \! syntax. the error just doesn't't show it. PerlMagick does seem to support that syntax I''ve used it in other scripts
Thanks for your help!
-
snibgo
- Posts: 11231
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Post
by snibgo » 2018-09-13T14:36:54-07:00
What symbol separates the numbers in "800×480"? It should be a lower-case letter "x". You seem to have something else.
EDIT: I've checked the code geometry.c GetGeometry(), and the separator can be upper or lower case (X or x) or ASCII 215, 0xD7, which is Unicode "multiplication sign". So maybe the code shown in the OP is correct, at least for some operations. But not if it is encoded as a multi-byte UTF sequence. I've always used "x", the lower-case letter.
-
garyash
- Posts: 5
- Joined: 2018-09-13T09:55:44-07:00
- Authentication code: 1152
Post
by garyash » 2018-09-13T18:49:30-07:00
I''ve got it working now... thank you so much
I'm embarrassed to say you seem to right about the x. It would appear that the size specification (I did a cut 'n paste from Apple''s website) likely contained a multiplication character that I mistook for a simple "x"
-
fmw42
- Posts: 24481
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Post
by fmw42 » 2018-09-13T19:10:13-07:00
Yes, I have noticed that as well on my Mac when I copy from the Preview inspector. Apple does not use a normal x there. So I always replace it when I copy and paste from there with a proper x.
Good catch from snibgo!