Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP creating thumbnails, vertical images changed to horizontal
    primarykey
    data
    text
    <p>Greetings...I'm resizing JPGs on the fly by directory. The photos are randomly horizontal or vertical in nature. My script (included below) works as expected - except in one specific case. That case would be when I transfer photos directly from a memory card to the final directory, from which the thumbs are created. In this case - my vertical photos generate horizontal thumbs.</p> <p>If I process a folder of images that have been processed, resized or not, this problem doesn't happen. The vertical photos are rotated on the camera, on the memory card and this is evidenced by the fact that on my local drive, verticals preview as verticals. However if I run untouched files through the thumbnail script, it rotates verticals 90 degrees clockwise!</p> <p>Does anyone smart out there have any ideas? :) </p> <p>Also I toyed with the idea of placing a 'rotate' button in my interface, but I can't get the php function rotateimage() to work. Samples are simle...no errors but in browser I get a mile of symbols and text. Seen that before?</p> <p>Thanks.</p> <pre><code> function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth ) { // open the directory $dir = opendir( $pathToImages ); // loop through it, looking for any/all JPG files: while (false !== ($fname = readdir( $dir ))) { // parse path for the extension $info = pathinfo($pathToImages . $fname); // continue only if this is a JPEG image if ( strtolower($info['extension']) == 'jpg' ) { echo "Creating thumbnail for {$fname} &lt;br /&gt;"; // load image and get image size $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" ); $width = imagesx( $img ); $height = imagesy( $img ); // calculate thumbnail size $new_width = $thumbWidth; $new_height = floor( $height * ( $thumbWidth / $width ) ); // create a new tempopary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); // copy and resize old image into new image //imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); imagecopyresampled( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); // save thumbnail into a file imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" ); } } // close the directory closedir( $dir ); } </code></pre>
    singulars
    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.
    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