Different way to deal with the thumbnail generator

  • Posts: 634
  • Thank you received: 16
6 years 4 months ago #295569

-- HikaShop version -- : 3.5
-- Joomla version -- : 3.8.9
-- PHP version -- : 7.1.4

I found a problem (not a bug, a problem) when I use the HikaShop provided function to create thumbnails $imageHelper->getThumbnail(---)

What happens is that if I request a thumbnail of a larger size that the source image it generates an error instead of creating an oversampled thumbnail.

I understand this works as expected by the creators of the getThumbnail function so i would like to suggest to make the function more versatile either making it tolerant to oversampling or making oversampling optional so it does generate a thumbnail no matter it is horrible to the eyes.

This would help a lot on developing smart solutions to create product_list views intended to maintain large sets of images that need to be photographed again by local e-commerce team when those images com from the a third supplier,

to make it clearer, I mean:

I have a shop where I wills ell products from different makers.

One of the makers is providing high resolution cool great pictures.

Others pictures are made in house.

A third provider usually (but not always) provides terrible shitty ugly low resolution pictures mixed with good ones.

I want quick product adoption to my shop once products are on the ship sailing to my country warehouse...

So I want my clients to already buy or reserve products no matter some pics are bad. Once the product arrives to me I make the good pictures.

$imageHelper->getThumbnail() seems not allowing me to make oversampled thumbnails ---> PLEASE LET'S GET UGLY BUT FUNCTIONAL THUMBNAILS made from a small image.

I am actually using this piece of code:

$imageHelper->getThumbnail($img, array(200,104), array('default' => 1, 'forcesize' => 1));


Additionally I feel the error message generated by this function is misleading the coder as it is not true that the target folder is unwritable.

See the attached image to see what i mean.

–––––

Any thought, opinion and suggested solution on the matter is welcome.

Bet regards,

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 4 months ago #295580

Hi,

We're happy to get feedback on that and improve the situation with the thumbnails generation.
However, I'm not able to reproduce the issue you're talking about.
For example, I used such code in the show_block_img view file to do my test and try to replicate your issue:

$res = $this->image->getThumbnail($image->file_path, array(2000,2400), array('default' => 1, 'forcesize' => 1));
echo '<img src="'.$res->url.'"/>';
My image original size is 640*480 so clearly, the size of the thumbnail requested is bigger than the size of the original image. And I do get a thumbnail of 2000*24000 for my image.
However, as you say, HikaShop doesn't allow for oversampling (because it's ugly), so instead I get my image with white area all around to fill the space to reach 2000*2400.
But no error.
I seems to me that the code example you're providing doesn't correspond to the code you're using to generate that error.
Could you provide more details on that ?

Please Log in or Create an account to join the conversation.

  • Posts: 634
  • Thank you received: 16
6 years 4 months ago #295610

Hi,

This is the code that generates the error:

$imageHelper->getThumbnail($img, array(0,100), array('default' => 1, 'forcesize' => 1));

Thanks for the answer.

--
Victor

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
6 years 4 months ago #295621

Hi,

Yes, in that case, I do get the error.
However, the problem here is that the code is not logical. You're asking the system to force the size of the thumbnail to a certain height/width but you don't provide both. In that case, you want to remove the forcesize parameter.

But well, we'll change the code so that even if you have the force size setting activated, if you don't provide both sizes, it will behave as if the option was turned off.
For that, we'll change the lines:

			'x' => empty($options['forcesize'])) ? $scaling[0] : $size['x'],
			'y' => empty($options['forcesize'])) ? $scaling[1] : $size['y'],
to:
			'x' => empty($options['forcesize']) || empty($size['x']) ? $scaling[0] : $size['x'],
			'y' => empty($options['forcesize']) || empty($size['y']) ? $scaling[1] : $size['y'],

The following user(s) said Thank You: PeterChain

Please Log in or Create an account to join the conversation.

Time to create page: 0.064 seconds
Powered by Kunena Forum