Note that there are some explanatory texts on larger screens.

plurals
  1. POError while creating thumbnails in PHP
    primarykey
    data
    text
    <p>This is my code for creating thumbnails. Here I'm attempting to check if the thumbnail already exists. If it does it's displayed directly. Else the thumbnail is created and then displayed.</p> <pre><code>&lt;a class="adiimage" rel="colorbox" title=" " href="new/artists/data/single_image.php?imageid=&lt;?php echo $rowa_image['product_image_id']; ?&gt;"&gt; &lt;!--&lt;img src="new/images/upload/&lt;?php echo $image; ?&gt;" alt="" border="0" /&gt;--&gt; &lt;?php $addr = $_SERVER['HOME']; echo '&lt;script&gt; alert("'.$addr.'"); &lt;/script&gt;'; /*$pathToImages = "../new/images/upload/"; $pathToThumbs = "../new/images/upload/thumbs/";*/ $pathToImages = "../new/images/upload/"; $pathToThumbs = "../new/images/upload/thumbs/"; $thumbWidth = 100; $filename = $pathToThumbs . $image; //check if thumbnail exists if(file_exists($filename)){ //display thumbnail ?&gt; &lt;img src="&lt;?php echo $filename; ?&gt;" alt="" border="0" /&gt; &lt;?php } else{ //create thumbnail createThumbs($pathToImages, $pathToThumbs, $thumbWidth, $image); //createThumbs("new/images/upload/","new/images/upload/thumbs/",100); ?&gt; &lt;img src="&lt;?php echo $filename; ?&gt;" alt="" border="0" /&gt; &lt;?php } } ?&gt; &lt;/a&gt; &lt;!--&lt;/div&gt;--&gt; &lt;/li&gt; &lt;?php } } } ?&gt; &lt;/ul&gt; &lt;/div&gt; &lt;?php //thumbnail creation function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth, $image ) { // open the directory //$dir = opendir( $pathToImages ); $dir = fopen($pathToImages, "rw"); /* read the source image */ $file = $pathToImages . $image; //echo '&lt;script&gt; alert("'.$file.'"); &lt;/script&gt;'; $source_image = imagecreatefromjpeg($pathToImages); //$source_image = imagecreatefromjpeg( "{$pathToImages}{$image}" ); $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */ $desired_height = floor($height * ($thumbWidth / $width)); /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($thumbWidth, $desired_height); /* copy source image at a resized size */ imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $thumbWidth, $desired_height, $width, $height); /* create the physical thumbnail image to its destination */ //imagejpeg($virtual_image, $pathToThumbs); imagejpeg($virtual_image, "{$pathToThumbs}{$image}"); } ?&gt; </code></pre> <p>The above code is giving me the following error which I don't know how to solve. I think that the file path is the issue. But I'm not sure what's exactly wrong.</p> <pre><code>Warning: fopen(../new/images/upload/) [ function.fopen ]: failed to open stream: No such file or directory in /home/artistiv/public_html/new/publicprofile/artist_image.php on line 107 Warning: imagecreatefromjpeg(../new/images/upload/) [ function.imagecreatefromjpeg ]: failed to open stream: No such file or directory in /home/artistiv/public_html/new/publicprofile/artist_image.php on line 111 Warning: imagesx() expects parameter 1 to be resource, boolean given in /home/artistiv/public_html/new/publicprofile/artist_image.php on line 114 Warning: imagesy() expects parameter 1 to be resource, boolean given in /home/artistiv/public_html/new/publicprofile/artist_image.php on line 115 Warning: Division by zero in /home/artistiv/public_html/new/publicprofile/artist_image.php on line 118 Warning: imagecreatetruecolor() [ function.imagecreatetruecolor ]: Invalid image dimensions in /home/artistiv/public_html/new/publicprofile/artist_image.php on line 121 Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in /home/artistiv/public_html/new/publicprofile/artist_image.php on line 124 Warning: imagejpeg() expects parameter 1 to be resource, boolean given in /home/artistiv/public_html/new/publicprofile/artist_image.php on line 128 </code></pre> <p>When I used opendir function too it gave me the following error:</p> <pre><code>function.imagecreatefromjpeg ]: failed to open stream: No such file or directory in /home/artistiv/public_html/new/publicprofile/artist_image.php on line 110 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload