Writing an image file - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Writing an image file

davidrtgdavidrtg Posts: 95Member
I've got a script here that is causing some problems when trying to Write()image information. I've narrowed it down the the line that I have commented out. The weird thing is it works on about 80% of people that use it but others it doesn't. I've noticed that most of the people it doesn't work for are on slower internet connections but i've also got a person i'm working with thats on highspeed?
[code]
$image = Image::Magick->new;
open(IMAGE,"$imgpath/$filename");
$image->Read(file=>IMAGE);
close(IMAGE);
($height,$width) = $image->Get('height','width');
$newwidth = 100;
$newheight = ($height % $width) * $newwidth;
$geometry = $newwidth . 'x' . $newheight;
$image->Resize(geometry=>$geometry);
$oldfilename = $filename;
$filename =~ s/_f_/_t_/;
open(IMAGE,">$imgpath/$filename");
# $image->Write(file=>IMAGE,filename=>$filename);
close(IMAGE);
[/code]
Any ideas? I'm at a loss =

Comments

  • JonathanJonathan Posts: 2,914Member
    : I've got a script here that is causing some problems when trying to
    : Write()image information. I've narrowed it down the the line that I
    : have commented out. The weird thing is it works on about 80% of
    : people that use it but others it doesn't. I've noticed that most of
    : the people it doesn't work for are on slower internet connections
    : but i've also got a person i'm working with thats on highspeed?
    Hmmm...so are people uploading the image or is it just one already existing on the server that you are re-sizing?

    : [code]
    : $image = Image::Magick->new;
    : open(IMAGE,"$imgpath/$filename");
    : $image->Read(file=>IMAGE);
    : close(IMAGE);
    : ($height,$width) = $image->Get('height','width');
    : $newwidth = 100;
    : $newheight = ($height % $width) * $newwidth;
    : $geometry = $newwidth . 'x' . $newheight;
    : $image->Resize(geometry=>$geometry);
    : $oldfilename = $filename;
    : $filename =~ s/_f_/_t_/;
    : open(IMAGE,">$imgpath/$filename");
    : $image->Write(file=>IMAGE,filename => [red]"$imgpath/[/red]$filename[red]"[/red]);
    : close(IMAGE);
    : [/code]
    : Any ideas? I'm at a loss =
    :
    Also threw in a possible fix that may be needed there.

    If people are uploading images, look at the images they have uploaded and check they are OK. Garbage in = garbage out. Be careful of binary mode issues on different platforms (e.g. Win32).

    Also, is there any correlation between problems and input image format?

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • davidrtgdavidrtg Posts: 95Member
    [b][red]This message was edited by davidrtg at 2004-2-24 13:15:23[/red][/b][hr]
    [b][red]This message was edited by davidrtg at 2004-2-24 13:12:5[/red][/b][hr]
    : : I've got a script here that is causing some problems when trying to
    : : Write()image information. I've narrowed it down the the line that I
    : : have commented out. The weird thing is it works on about 80% of
    : : people that use it but others it doesn't. I've noticed that most of
    : : the people it doesn't work for are on slower internet connections
    : : but i've also got a person i'm working with thats on highspeed?
    : Hmmm...so are people uploading the image or is it just one already existing on the server that you are re-sizing?
    :
    : : [code]
    : : $image = Image::Magick->new;
    : : open(IMAGE,"$imgpath/$filename");
    : : $image->Read(file=>IMAGE);
    : : close(IMAGE);
    : : ($height,$width) = $image->Get('height','width');
    : : $newwidth = 100;
    : : $newheight = ($height % $width) * $newwidth;
    : : $geometry = $newwidth . 'x' . $newheight;
    : : $image->Resize(geometry=>$geometry);
    : : $oldfilename = $filename;
    : : $filename =~ s/_f_/_t_/;
    : : open(IMAGE,">$imgpath/$filename");
    : : $image->Write(file=>IMAGE,filename => [red]"$imgpath/[/red]$filename[red]"[/red]);
    : : close(IMAGE);
    : : [/code]
    : : Any ideas? I'm at a loss =
    : :
    : Also threw in a possible fix that may be needed there.
    :
    : If people are uploading images, look at the images they have uploaded and check they are OK. Garbage in = garbage out. Be careful of binary mode issues on different platforms (e.g. Win32).
    :
    : Also, is there any correlation between problems and input image format?
    :
    : Jonathan
    :
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

    Looks like it might be a problem with duplicate names on the server that it doesn't like. Double checking that now, hope thats it!

    Thanks!
    David




  • davidrtgdavidrtg Posts: 95Member
    [b][red]This message was edited by davidrtg at 2004-2-25 10:5:45[/red][/b][hr]
    : : Also threw in a possible fix that may be needed there.
    : :
    : : If people are uploading images, look at the images they have uploaded and check they are OK. Garbage in = garbage out. Be careful of binary mode issues on different platforms (e.g. Win32).
    : :
    : : Also, is there any correlation between problems and input image format?
    : :
    : : Jonathan
    : :
    : : ###
    : : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    : :
    : :
    :
    : Looks like it might be a problem with duplicate names on the server that it doesn't like. Double checking that now, hope thats it!
    :

    Well, it wasn't that. I added the change and its still stopping at this line of code.
    [code]$image->Write(file=>IMAGE,filename=>"$imgpath/$filename") || print "Unable to write $filename: $!";[/code]
    I get the print statement but no error value in $!.

    EDIT: Just found that it does the || print if there is a problem or not.


  • WeirdofreakWeirdofreak Posts: 439Member
    You need to use or, not ||. It's a matter of precedence.
Sign In or Register to comment.