#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    11
    Rep Power
    0

    Imagecreatefromjpeg() and URL IMAGE PATH contain dynamic values from database


    imagecreatefromjpeg() and the URL IMAGE PATH contain dynamic values from database not working



    The Url with calling dynamic values from database not working for imagecreatefromjpeg('$file_path'). There must some quotes or slashes need to be include in the $file_path url. What will be the correct representation of the path as in this situation?

    Kindly Advice

    Thanks in advance


    Image.php
    =========

    PHP Code:
    <?php
        file_path 
    'images/'.$imagebelow[$i]['id'].'_thumb.'.$imagebelow[$i]['extension'];
        
    //echo $file_path;
        //$file_path = 'images/458_thumb.jpg';  // Displaying image with this simplest path

        // Load the stamp and the photo to apply the watermark to
        
    $stamp imagecreatefrompng('../../images/watermark.png');
        
    $im imagecreatefromjpeg($file_path);

        
    // Set the margins for the stamp and get the height/width of the stamp image
        
    $marge_right 0;
        
    $marge_bottom 10;

        
    $sx imagesx($stamp);
        
    $sy imagesy($stamp);
        
    // Copy the stamp image onto our photo using the margin offsets and the photo 
        // width to calculate positioning of the stamp. 
        
    imagecopy($im$stampimagesx($im) - $sx $marge_rightimagesy($im) - $marge_bottom $sy00imagesx($stamp), imagesy($stamp));

        
    // Output and free memory
        
    header('Content-type: image/png');
        
    imagepng($im);
        
    imagedestroy($im);
        
    ?>
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    11
    Rep Power
    0
    It is the simple question. Is anyone for the solution please?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,974
    Rep Power
    375
    is this script in one folder "above" the images folder?

    if you put the actual path inside this function: $im = imagecreatefromjpeg(); instead of creating it dynamically, does it work?

    I dont think being dynamic has anything to do with your problem
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    11
    Rep Power
    0
    Originally Posted by paulh1983
    is this script in one folder "above" the images folder?

    if you put the actual path inside this function: $im = imagecreatefromjpeg(); instead of creating it dynamically, does it work?

    I dont think being dynamic has anything to do with your problem
    Yes! It working with actual path as I mentioned in my post in line# 4 as
    PHP Code:
    //$file_path = 'images/458_thumb.jpg'; // Displaying image with this simplest path 
    Everything is working fine except when I replace $FILE_PATH value with
    PHP Code:
    'images/'.$imagebelow[$i]['id'].'_thumb.'.$imagebelow[$i]['extension'
    so it means there is wrong with some quotes this path as dynamically call for images from database is essential part of the application.
  8. #5
  9. No Profile Picture
    I haz teh codez!
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2003
    Posts
    2,548
    Rep Power
    2337
    Basic PHP debugging.

    What is the value of dynamically-generated $file_path, because this line

    php Code:
    file_path = 'images/'.$imagebelow[$i]['id'].'_thumb.'.$imagebelow[$i]['extension'];


    is missing something important.
    I ♥ ManiacDan & requinix

    This is a sig, and not necessarily a comment on the OP:
    Please don't be a help vampire!
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    11
    Rep Power
    0
    Originally Posted by ptr2void
    Basic PHP debugging.

    What is the value of dynamically-generated $file_path, because this line

    php Code:
    file_path = 'images/'.$imagebelow[$i]['id'].'_thumb.'.$imagebelow[$i]['extension'];


    is missing something important.

    Original file
    -------------
    Before the code displaying images in the Original file like this:

    PHP Code:
     <?php $imagebelow Helper::getimagebelow($_REQUEST['data']);
                          
                  if(!empty(
    $imagebelow))
                { 
                                
                                for(
    $i=0;$i<count($imagebelow);$i++){
                                
    ?>       
                                                    <img src="<?php echo  FRONT_MODULES_PATH_HTTP.'images/'.$imagebelow[$i]['id'].'_thumb.'.$imagebelow[$i]['extension'];?>"/>
                            
                                    <?php }} else{?>
                    <img src ="<?php echo FRONT_IMG_PATH.'building.png';?>" />
                <?php ?>
    And after applying watermark the <img /> tag in the code now look like this:

    PHP Code:
     <?php $imagebelow Helper::getimagebelow($_REQUEST['data']);
                          
                  if(!empty(
    $imagebelow))
                { 
                                
                                for(
    $i=0;$i<count($imagebelow);$i++){
                                
    ?>
                                        <img src="show.php"/>
                    
                                    <?php }} else{?>
                    <img src ="<?php echo FRONT_IMG_PATH.'building.png';?>" />
                <?php ?>

    show.php
    --------

    PHP Code:
    <?php include_once('image.php'); ?>
    image.php
    ---------

    PHP Code:
    <?php 
        $file_path 
    FRONT_MODULES_PATH_HTTP.'images/'.$imagebelow[$i]['id'].'_thumb.'.$imagebelow[$i]['extension']; 
        
    //echo $file_path; 
        //$file_path = 'images/458_thumb.jpg';  // Displaying image with this simplest path 

        // Load the stamp and the photo to apply the watermark to 
        
    $stamp imagecreatefrompng('../../images/watermark.png'); 
        
    $im imagecreatefromjpeg($file_path); 

        
    // Set the margins for the stamp and get the height/width of the stamp image 
        
    $marge_right 0
        
    $marge_bottom 10

        
    $sx imagesx($stamp); 
        
    $sy imagesy($stamp); 
        
    // Copy the stamp image onto our photo using the margin offsets and the photo  
        // width to calculate positioning of the stamp.  
        
    imagecopy($im$stampimagesx($im) - $sx $marge_rightimagesy($im) - $marge_bottom $sy00imagesx($stamp), imagesy($stamp)); 

        
    // Output and free memory 
        
    header('Content-type: image/png'); 
        
    imagepng($im); 
        
    imagedestroy($im); 
        
    ?>
    This is how the code is ... Kindly let me know what is missing in it? As it gives Error in Mozilla and says "The image '......' cannot displayed because it contains errors." and in Chrome shows blank page with a broken image icon.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    11
    Rep Power
    0
    Yes! anyone who can rectify this problem and resolve it or tell me what I am missing? Its already taken my whole day... AAH..

IMN logo majestic logo threadwatch logo seochat tools logo