Skip to content

Commit

Permalink
Merge pull request #2614 from phili67/phili67-photo-bug-res2
Browse files Browse the repository at this point in the history
Photo update
  • Loading branch information
phili67 committed Apr 16, 2024
2 parents 3c6b3a6 + 9345e3c commit 0ac1618
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/EcclesiaCRM/dto/Photo.php
Expand Up @@ -132,13 +132,15 @@ private function getGDImage($sourceImagePath) {
private function createThumbnail() {
$thumbWidth = SystemConfig::getValue("iThumbnailWidth");
$img = $this->getGDImage($this->photoURI); //just in case we have legacy JPG/GIF that don't have a thumbnail.
$width = imagesx( $img );
$height = imagesy( $img );
$new_width = $thumbWidth;
$new_height = floor( $height * ( $thumbWidth / $width ) );
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
imagejpeg($tmp_img, $this->photoThumbURI, 50);
if (is_resource($img) || $img instanceof \GdImage) {
$width = imagesx( $img );
$height = imagesy( $img );
$new_width = $thumbWidth;
$new_height = floor( $height * ( $thumbWidth / $width ) );
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
imagejpeg($tmp_img, $this->photoThumbURI, 50);
}
}

public function getThumbnailBytes() {
Expand Down

0 comments on commit 0ac1618

Please sign in to comment.