webtrees
webtrees copied to clipboard
Image files truncated
Latest dev version.
Photos on individual page are truncated. If you log in you see the full picture
That will be the new version of the intervention/image library.
still exists in 2.2.0. adding the watermark to the text reduces the visible image height to 100, the rest is filled with white space.
reduces the visible image to 100 x 100 - the original height is retained.
Workaround: Change in ImageFactory function mediaFileThumbnailResponse line 201
from $watermark = $this->createWatermark(width: $image->width(), height: $image->height(), media_file: $media_file);
to $watermark = $this->createWatermark(width: $width, height: $height, media_file: $media_file);
$image->width returns in this example 113 the value of the watermark and not the intended value 200 of the thumbnail
Fix: use function scale instead of contain for scaling the watermark see scale https://image.intervention.io/v3/modifying/resizing#resizing-images-proportionally vs. contain https://image.intervention.io/v3/modifying/resizing#padded-resizing-with-upscaling
Change ImageFactory function createWatermark line 255
->scale(width: $width, height: $height);
Change in ImageFactory function mediaFileThumbnailResponse line 201
I don't think this is the answer.
If an image is 300x600, and we are creating a thumbnail to fit inside 100x100, then we will have an image 50x100.
The width of the watermark needs to be 50 ($image->width()), not 100 ($width).
I think the issue lies at line 263:
return $image->place(element: $watermark, position: 'center');
This function takes another parameter "opacity". Here's the result with values of 0, 25, 50, 75 and 100 (default):
I guess this function isn't doing what I expect...
Here is the documentation for the function: https://image.intervention.io/v3/modifying/inserting
Aha! We are creating the watermark incorrectly....
@FrankWarius - I only saw your second comment after I had come to the same conclusion. I could have saved an hour... :-)