Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

mogrify not working

by rbhyland (Acolyte)
on Mar 02, 2014 at 19:05 UTC ( [id://1076727]=perlquestion: print w/replies, xml ) Need Help??

rbhyland has asked for the wisdom of the Perl Monks concerning the following question:

I am running the code below. I want to flip the file passed in Slide_name. The mogrify command between the backticks looks correct to me, but it doesn't seem to do anything. What am I doing wrong? Appreciate any suggestions...

#!/usr/bin/perl -w use strict; use warnings; use Image::Magick; use CGI::Carp qw(fatalsToBrowser); use CGI::Pretty; use CGI qw(:standard :cgi-lib -debug fatalsToBrowser warningsToBrowser +); my $cgi = new CGI; print $cgi->header; print start_html; my $slide_name = "../".param('slide_name'); print "$slide_name",br; print img({-src=>"$slide_name"}),br; `/usr/bin/mogrify -flip $slide_name`; print img({-src=>"$slide_name"}),br; #print redirect(referer()); print end_html;

Replies are listed 'Best First'.
Re: mogrify not working
by onelander (Sexton) on Mar 02, 2014 at 19:48 UTC
    A few points. Are you sure that slide_name is being passed? You may want to save the mogrify command output to a variable and look at what is returns.
    my $ret = `/usr/bin/mogrify -flip $slide_name`; print "\n" . $ret . "\n";
      I have printed the slide_name and it is OK. I printed the mogrify command without any parameters and got its explanatory usage text. When I print the before and after images there is no change.
      I tried your code and it worked! But only once. When I ran the script again it didn't flip the picture back. ?!
        "I tried your code and it worked! But only once. When I ran the script again it didn't flip the picture back. ?!"

        It's possible the image is being cached: what's displayed in the browser may just be a copy of what was displayed from the last run. Check the actual file on disk to see if it's being flipped between runs.

        If it is a caching issue, you may need to set a short expiration date. See CGI: CREATING A STANDARD HTTP HEADER for details.

        -- Ken

      Printing $ret gives nothing at all.
        "Printing $ret gives nothing at all."

        See perlop: Quote-Like Operators for information about what's returned by `...` and how to change it.

        -- Ken

        I just ran that mogrify command and it does not return anything if it appears to run correctly.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1076727]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-20 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found