SuperOfficeDocs / feedback

Contains feedback issues created by the community. Feedback issues are created by readers who click the feedback button on content pages in the docs.superoffice.com website.
MIT License
2 stars 0 forks source link

Feedback for Select product image - details of how image is processed #219

Closed acdavidh closed 1 month ago

acdavidh commented 1 month ago

There should be more documentation on how the product image thumbnails are generated, the documentation currently says:

"We recommend that you use an image size of 130 x 180 pixels. If the image is bigger than that, it is cropped on the bottom and the right edge."

But that seems strange advice, since the software will create a thumbnail based on the image you upload, so if you already have a very small image and a thumbnail is generated you lose a lot of detail.

There also a preference 'JPEQ quality' which I an not sure has impact on the images upload here?

image

There also a preference 'product thumbnail size (pixels)'

image

When we changed that to a higher value (in our case 600px) the image that is set inside the quote details is a lot less compressed/more detail.

We found this preference from this bug: https://community.superoffice.com/en/product-releases/bugs-wishes/product-issue/?bid=40988&azure=1

Would be great if there is some more documentation on how these preferences influence the image in the quote details, because the default settings cause a very poor quality image to be generated.


Document Details

Do not edit this section. It is required for docs.superOffice.com ➟ Docs Team processing.

SuperOfficeDevNet commented 1 month ago

Hi @acdavidh!

When a product image is created, via the BlobAgent.SetProductImage method, it creates both the product image and the thumbnail at the same time.

Once the original is saved, the thumbnail is generated using the thumbnail preference you referenced. If one is not set, it defaults to 150, and used to create a 150x150 thumbnail.

The actual scaling is done a private static method called NewDimensions within the ImageUtilities class. This method is responsible for calculating the dimensions of a new image while maintaining the aspect ratio of the original image. The method takes in 4 parameters, and outputs 2: • actualX and actualY: The actual width and height of the original image. • maxX and maxY: The maximum width and height that the new image should fit into. This is from the preference • newX and newY: Output parameters that will hold the calculated width and height of the new image.

The method first checks if the actual dimensions of the original image are already smaller or equal to the maximum dimensions specified. If so, it means that the original image can fit inside the new dimensions without any scaling. In this case, the method sets newX and newY to the actual dimensions and returns false to indicate that no rescaling is needed.

If the actual dimensions of the original image are larger than the maximum dimensions, the method calculates a scaling factor by dividing the larger dimension (either actualX or actualY) by the corresponding maximum dimension (maxX or maxY). The scaling factor ensures that the new image will fit within the maximum dimensions while maintaining the original aspect ratio.

The method then calculates the new width and height of the image by dividing the actual dimensions by the scaling factor and rounding the result to the nearest integer. These new dimensions represent the maximum size that the image can be while still fitting within the specified maximum dimensions.

Finally, the method sets newX and newY to the calculated dimensions and returns true to indicate that a rescaling is needed.

Overall, this method is used to determine whether an image needs to be resized to fit within certain dimensions while preserving its aspect ratio.

To create a better thumbnail image, use the BlobAgent.SetProductThumbnail to override the default.

I hope this helps!

acdavidh commented 1 month ago

@SuperOfficeDevNet This very useful for developers, thanks! But this question actually came from our functional consultant that was working on this for a customer. I don't think this explanation will help him 😉 (although it does confirm our internal documentation we created for this). Some kind of functional documentation added to docs about the mentioned preference (and how it scales using the aspect ratio like you mentioned) would be great.

To confirm, the 'JPEQ quality' preference does not effect the product image upload at all?

SuperOfficeDevNet commented 1 month ago

@acdavidh,

Correct, the JPEG quality doesn't seems to referenced anywhere in the code base. It may had once with the WIndows client, but nowhere I could find.