imageCreateFromJPEG Not working

Discussion in 'Installation/Configuration' started by lifeisboost, Feb 24, 2006.

  1. lifeisboost

    lifeisboost New Member

    Hello All,

    I used the perfect setup for fedora C3, GD is installed. My only issue is imageCreateFromJPEG does not work. does anyone have any help they can offer? do i need to recompile php diffrerently?
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Any error messages? Anything in the logs?
     
  3. lifeisboost

    lifeisboost New Member

    here is a snippet of the log

    Undefined variable: src in /home/www/web5/web/getimgclass.php on line 6, referer: http$
    [client 166.102.29.115] PHP Warning: imagesx(): supplied argument is not a valid Image resource in /home/www/web5/web/getim$
    [client 166.102.29.115] PHP Warning: imagesy(): supplied argument is not a valid Image resource in /home/www/web5/web/getim$
    [client 166.102.29.115] PHP Warning: imagealphablending(): supplied argument is not a valid Image resource in /home/www/web$
    [client 166.102.29.115] PHP Warning: imagecopy(): supplied argument is not a valid Image resource in /home/www/web5/web/get$
    [client 166.102.29.115] PHP Warning: imagejpeg(): supplied argument is not a valid Image resource in /home



    what this script does is add a watermark to each image as it is viewed and is all custom coded.
     
  4. lifeisboost

    lifeisboost New Member

    also imageCreateFromPNG will not work. i check php config and it shows the correct GD version installed and imagmagick is installed im kinda stumped
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    For me these errors looks like you are either pointing the PHP image functions to an non image file or the path to the image file is incorrect.
     
  6. lifeisboost

    lifeisboost New Member

    this is the scrip that isn;t working. it pulls the images from a database. and they are all in the correct locations.

    PHP:
    <?php
    Header
    "Content-type: image/jpeg");


    $im "/home/www/web5/web/watermark/sfslogo.png";
    $src "$src";

    // create the resource id
    $image_id imageCreateFromPNG($im);

    // get image size
    $im_x ImageSX($image_id);
    $im_y ImageSY($image_id);

    // background image 
    $backgroundimage imageCreateFromJPEG($src);

    $bk_x ImageSX($backgroundimage);
    $bk_y ImageSY($backgroundimage);

    $dest_x = ( $bk_x ) - ( $im_x ); 
    $dest_y = ( $bk_y ) - ( $im_y ); 


    // merge the two together with alphsablending on!
    ImageAlphaBlending($backgroundimagetrue);
    imagecopy($backgroundimage$image_id$dest_x$dest_y00$im_x$im_y);

    ImageJPEG($backgroundimage);

    // destroy the memory
    ImageDestroy($backgroundimage);
    ImageDestroy($image_id);
    ?> 
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Does this script works on another server. I'am pretty sure that the problem is related to the .png file that you try to open. If the imagecreate functions where not compiled in correctly in your php you would get different error messages.
     
  8. falko

    falko Super Moderator Howtoforge Staff

    I think you have to check the script:

    Code:
    <?php
    Header( "Content-type: image/jpeg");
    
    
    $im = "/home/www/web5/web/watermark/sfslogo.png";
    [B][COLOR="Red"]$src = "$src";[/COLOR][/B]
    
    // create the resource id
    $image_id = imageCreateFromPNG($im);
    
    // get image size
    $im_x = ImageSX($image_id);
    $im_y = ImageSY($image_id);
    
    // background image
    [B][COLOR="Red"]$backgroundimage = imageCreateFromJPEG($src);[/COLOR][/B]
    
    $bk_x = ImageSX($backgroundimage);
    $bk_y = ImageSY($backgroundimage);
    
    $dest_x = ( $bk_x / 2 ) - ( $im_x / 2 );
    $dest_y = ( $bk_y / 2 ) - ( $im_y / 2 );
    
    
    // merge the two together with alphsablending on!
    ImageAlphaBlending($backgroundimage, true);
    imagecopy($backgroundimage, $image_id, $dest_x, $dest_y, 0, 0, $im_x, $im_y);
    
    ImageJPEG($backgroundimage);
    
    // destroy the memory
    ImageDestroy($backgroundimage);
    ImageDestroy($image_id);
    ?> 
    $src is not defined in that script, that's why imageCreateFromJPEG($src) fails.
     
  9. lifeisboost

    lifeisboost New Member

    the script works perfectly on a cpanel server. the coder imworking with insists its the server configuration :( the source comes from another file that calls this script.
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    Please make a new PHP script with the content:


    Code:
    <?php
    
    $image_id = imageCreateFromPNG("/home/www/web5/web/watermark/sfslogo.png");
    
    ?>
    Make sure you deactivate PHP safemode in this website and that the file /home/www/web5/web/watermark/sfslogo.png really exist. Then call the script in a webbrowser. Do you get an error?
     

Share This Page