Problem with Read() in PerlMagick

Discussion in 'Perl Misc' started by guba@vi-anec.de, Apr 24, 2007.

  1. Guest

    Hello,

    I have txt files with paths of image files and
    parameter values for image processing operations
    in PerlMagick. The structure is like this:

    name of the variable without $
    variable value

    for example:

    ....
    background_jp2_path
    E:/ART/IM_Composing/Planes/2004/Tile14/T14-2004_04_30a-1-16T.JP2
    crop_width
    1222
    background_x
    2123
    background_y
    192
    background_x_roll
    489
    ....

    I wrote a program that reads such txt files,
    defines the variables and gets the variable
    values like
    $background_jp2_path = 'E:/ART/...'
    I checked that all variables have the right
    values with the print command.

    But if I want to read the image file with
    $background->Read("$background_jp2_path");
    nothing happens!!
    The variable has for sure
    the right value and the file exists at the
    right place which is proven by inserting
    the path value by hand
    $background->Read("E:/ART/...");
    and this works.

    Why is the Read()-command not working?
    Thank you very much!
    , Apr 24, 2007
    #1
    1. Advertising

  2. -berlin.de Guest

    <> wrote in comp.lang.perl.misc:
    > Hello,
    >
    > I have txt files with paths of image files and
    > parameter values for image processing operations
    > in PerlMagick. The structure is like this:
    >
    > name of the variable without $
    > variable value
    >
    > for example:
    >
    > ...
    > background_jp2_path
    > E:/ART/IM_Composing/Planes/2004/Tile14/T14-2004_04_30a-1-16T.JP2
    > crop_width
    > 1222
    > background_x
    > 2123
    > background_y
    > 192
    > background_x_roll
    > 489
    > ...
    >
    > I wrote a program that reads such txt files,
    > defines the variables and gets the variable
    > values like
    > $background_jp2_path = 'E:/ART/...'
    > I checked that all variables have the right
    > values with the print command.
    >
    > But if I want to read the image file with
    > $background->Read("$background_jp2_path");


    The quotes around $background_jp2_path are not
    needed.

    > nothing happens!!


    Nothing can happen in various ways. We need
    that info. Does it hang? Return immediately?
    What is the value of $background afterwards?
    Does PerlMagick have diagnostics? A debug mode?
    What do they say?

    > The variable has for sure
    > the right value and the file exists at the


    Are you sure? Have you checked against a rogue
    line feed at the end of th string?

    > Why is the Read()-command not working?
    > Thank you very much!


    You haven't given us any information that could
    help answer that question.

    Anno
    -berlin.de, Apr 24, 2007
    #2
    1. Advertising

  3. Guest

    Hello Anno,

    thank you for answering.


    > Return immediately?


    Yes it returns directly. I included a
    $background->Write() but nothing is
    written so I conclude the object is
    empty because nothing was read in
    this configuration; everything is working
    fine when I checked the functionality
    by inserting the path by hand.



    > Have you checked against a rogue
    > line feed at the end of th string?


    This is maybe a starting point because only
    the use of file paths are here a problem; all
    other variables&values are working. To what
    must I pay attention when checking it with
    print "$background_jp2_path";
    or how else could this be checked?
    Thank you very much!

    best regards
    Guenter



    -berlin.de schrieb:
    > <> wrote in comp.lang.perl.misc:
    > > Hello,
    > >
    > > I have txt files with paths of image files and
    > > parameter values for image processing operations
    > > in PerlMagick. The structure is like this:
    > >
    > > name of the variable without $
    > > variable value
    > >
    > > for example:
    > >
    > > ...
    > > background_jp2_path
    > > E:/ART/IM_Composing/Planes/2004/Tile14/T14-2004_04_30a-1-16T.JP2
    > > crop_width
    > > 1222
    > > background_x
    > > 2123
    > > background_y
    > > 192
    > > background_x_roll
    > > 489
    > > ...
    > >
    > > I wrote a program that reads such txt files,
    > > defines the variables and gets the variable
    > > values like
    > > $background_jp2_path = 'E:/ART/...'
    > > I checked that all variables have the right
    > > values with the print command.
    > >
    > > But if I want to read the image file with
    > > $background->Read("$background_jp2_path");

    >
    > The quotes around $background_jp2_path are not
    > needed.
    >
    > > nothing happens!!

    >
    > Nothing can happen in various ways. We need
    > that info. Does it hang? Return immediately?
    > What is the value of $background afterwards?
    > Does PerlMagick have diagnostics? A debug mode?
    > What do they say?
    >
    > > The variable has for sure
    > > the right value and the file exists at the

    >
    > Are you sure? Have you checked against a rogue
    > line feed at the end of th string?
    >
    > > Why is the Read()-command not working?
    > > Thank you very much!

    >
    > You haven't given us any information that could
    > help answer that question.
    >
    > Anno
    , Apr 24, 2007
    #3
  4. -berlin.de Guest

    <> wrote in comp.lang.perl.misc:
    > -berlin.de schrieb:


    [attribution restored, snippage]

    > > Have you checked against a rogue
    > > line feed at the end of th string?

    >
    > This is maybe a starting point because only
    > the use of file paths are here a problem; all
    > other variables&values are working. To what
    > must I pay attention when checking it with
    > print "$background_jp2_path";
    > or how else could this be checked?


    The simplest test would be to chomp() the variable
    before using it and see if it works then.

    Otherwise, look at the output of

    print "$background_jp2_path";

    The cursor should be at the end of the line, after the "h".
    If it is at the beginning of the next line, the variable
    ends with a line feed.

    Anno
    -berlin.de, Apr 24, 2007
    #4
  5. Guest

    Hello Anno,

    your first suggestion was right it was a rogue line feed.
    Thank you!

    Guenter
    , Apr 27, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Randell D.

    CPANing PerlMagick and it fails

    Randell D., Aug 25, 2003, in forum: Perl
    Replies:
    0
    Views:
    1,192
    Randell D.
    Aug 25, 2003
  2. kenny
    Replies:
    7
    Views:
    159
    kenny
    Apr 19, 2004
  3. rossz

    perlmagick and image size

    rossz, May 18, 2004, in forum: Perl Misc
    Replies:
    7
    Views:
    304
    dan baker
    May 21, 2004
  4. Aaron Dalton

    PerlMagick, Annotate, and Webdings

    Aaron Dalton, Mar 5, 2005, in forum: Perl Misc
    Replies:
    5
    Views:
    248
    Ron Savage
    Mar 27, 2005
  5. PerlMagick Cropping Help

    , Apr 21, 2005, in forum: Perl Misc
    Replies:
    6
    Views:
    197
Loading...

Share This Page