Image crop issue

I’m having trouble getting the image cropping to work as I expect it to. What I want is to have the image no wider than 800 and no higher than 1580. I try to do it like this.

.GetImageUrls(_fileService, i => new ImageSize { MaxSize = new Size(800, 1580) })

For most images this seem to work but for this one it acts strange as its not keeping the entire content. Am I doing this wrong?

Original image (6152 x 4358 px):

Cropped image (800 x 567 px):

Litium version: 7.3.2

What if you pass in MinSize as well so it is not Empty?

How does the GetImageUrls-method look like?

.GetImageUrls(_fileService, i => new ImageSize { MaxSize = new Size(800, 1580), MinSize = new Size(800, 1)}); made no difference.

Yeah. Sorry. It’s the default implementation in the Accelerator. Litium.Accelerator.Extensions.FieldFrameworkExtensions

public static List<string> GetImageUrls(this IFieldFramework fields, FileService fileService, Func<int, ImageSize> getImageSize = null)
	if (fields == null)
		return null;

	var imageIds = (fields[SystemFieldDefinitionConstants.Images] as IReadOnlyCollection<Guid>)?.ToArray();
	if (imageIds?.Length > 0)
		var result = new List<string>();
		for (int i = 0; i < imageIds.Length; i++)
			ImageSize imageSize = null;
			if (getImageSize != null)
				imageSize = getImageSize(i);
			var file = fileService.Get(imageIds[i]);
			var link = (imageSize != null)
				? file.GetUrlToImage(imageSize.MaxSize, imageSize.MinSize, out Size actualSize, false)
				: file.GetUrlToImage(out actualSize, false);

		return result;
		return null;

Please, can you verify the original image size?

When I download that original image that you have uploaded the size says 4655x2481. What is the size Litium recognize for this image and what is the size if you upload the image again?

The MinSize parameter is only used when the original image size is smaller than what you want so that should not have any impact.

Hi. Yes, that was it. The size in Litium differed from what the actual size of the image was.

Is the image imported by some integration or uploaded manually? More to be able to identify what have happen to get the wrong size.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.