webtrees icon indicating copy to clipboard operation
webtrees copied to clipboard

Image files truncated

Open makitso opened this issue 1 year ago • 1 comments
trafficstars

Latest dev version. Photos on individual page are truncated. If you log in you see the full picture image

image

makitso avatar Oct 12 '24 17:10 makitso

That will be the new version of the intervention/image library.

fisharebest avatar Oct 13 '24 21:10 fisharebest

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.


media-thumbnail

reduces the visible image to 100 x 100 - the original height is retained.

FrankWarius avatar Nov 25 '24 09:11 FrankWarius

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

FrankWarius avatar Nov 25 '24 14:11 FrankWarius

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);

FrankWarius avatar Nov 27 '24 10:11 FrankWarius

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):

opacity-0 opacity-25 opacity-50 opacity-75 opacity-100

I guess this function isn't doing what I expect...

Here is the documentation for the function: https://image.intervention.io/v3/modifying/inserting

fisharebest avatar Nov 30 '24 00:11 fisharebest

Aha! We are creating the watermark incorrectly....

fisharebest avatar Nov 30 '24 00:11 fisharebest

@FrankWarius - I only saw your second comment after I had come to the same conclusion. I could have saved an hour... :-)

fisharebest avatar Nov 30 '24 00:11 fisharebest