- /* sets new size */
- if($aspect_ratio < 1) {
- $new_w = $width;
- $new_h = abs($new_w * $aspect_ratio);
- } else {
- /* 'virtually' rotate the image and calculate it's ratio */
- $tmp_w = $cur_height;
- $tmp_h = $cur_width;
- /* now get the ratio from the 'rotated' image */
- $tmp_ratio = $tmp_h/$tmp_w;
- /* now calculate the new dimensions */
- $tmp_w = $width;
- $tmp_h = abs($tmp_w * $tmp_ratio);
-
- // now that we know, how high they photo should be, if it
- // gets rotated, use this high to scale the image
- $new_h = $tmp_h;
- $new_w = abs($new_h / $aspect_ratio);
-
- // If the image will be rotate because EXIF orientation said so
- // now 'virtually rotate' back the image for the image manipulation
- if($rotate == 90 || $rotate == 270) {
- $tmp = $new_w;
- $new_w = $new_h;
- $new_h = $tmp;
- }
- }
+ /* grabs the height and width */
+ $cur_width = imagesx($src_img);
+ $cur_height = imagesy($src_img);
+
+ // If requested width is more then the actual image width,
+ // do not generate a thumbnail, instead safe the original
+ // as thumbnail but with lower quality. But if the image
+ // is to heigh too, then we still have to resize it.
+ if($width >= $cur_width && $cur_height < $this->cfg->thumb_height) {
+ $result = imagejpeg($src_img, $thumb_image, 75);
+ imagedestroy($src_img);
+ return true;
+ }