Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cropped image dimensions by 30% is like 5% less size on memory #106

Closed
ghost opened this issue May 15, 2021 · 6 comments
Closed

Cropped image dimensions by 30% is like 5% less size on memory #106

ghost opened this issue May 15, 2021 · 6 comments

Comments

@ghost
Copy link

ghost commented May 15, 2021

note: I know the main purpose of this, is to smart crop, and this is already great. Still I have another problem

Context

I want to use this amazing library for uploads in browser. I tried to grab code from testsuite and it works fine.

Unfortunately I find in most cases:

Problem

cropped size in px / original size in px

is always way less than

cropped size in mb / original size in mb

I wished smartcrop.js would let the image quality as is, in this case I think size on memory would drop relatively to the cropped size ( logically as images are raw data? ).

Thanks a lot !!

@ghost ghost changed the title Cropped image by 30% is like 5% less size Cropped image dimensions by 30% is like 5% less size on memory May 15, 2021
@ghost
Copy link
Author

ghost commented May 15, 2021

I wished size would drop relatively as smartcrop is intended also for optimizing size. that would be great !

@jwagner
Copy link
Owner

jwagner commented May 18, 2021

Hi @bacloud14,

I'm not sure what you mean. smartcrop.js does not do anything to image quality nor does it do image compression - or anything else - to the image. It just gives you candidate crops. The test suite just draws on . It doesn't do image compression either.

Could you provide a bit more background on what you mean?

@ghost
Copy link
Author

ghost commented May 18, 2021

ok, I tried that "guitarist.jpg" file, cropped with var options = { debug: false, width: 250, height: 250 };

The result image of type 'png' with these observations:

guitarist.jpg is 427 * 640 px
canvas.png is 250 * 250 px

while
guitarist.jpg is 170KB
canvas.png is 146KB

I thought canvas.png would much less in file size.

Something near : ((250 * 250) / (427 * 640)) * 170 = 38.87 KB

@ghost
Copy link
Author

ghost commented May 18, 2021

Like when you take a paper, crop it with scissors, the amount of paper is always the same relatively to size.

@jwagner
Copy link
Owner

jwagner commented May 19, 2021

You are really comparing apples and oranges here. PNG and JPEG compress data differently. PNG is generally a quite bad choice to compress photographs. Maybe https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Image_types#choosing_an_image_format or https://www.freecodecamp.org/news/best-image-format-for-web-in-2019-jpeg-webp-heic-avif-41ba0c1b2789/ help you understand that a bit better.

But that really doesn't have anything to do with smartcrop. Smartcrop doesn't produce jpegs or pngs - it just gives you crops.

@ghost
Copy link
Author

ghost commented May 19, 2021

Probably I mistakenly change the name of the output file to PNG.
So I assume crop doesn't change extension I mean I'm sure now.
Anyway, my question was clear on why the crop size is not relative to the new size.
Anyway closing this as I seem not to be presenting the idea well. Thanks.

@ghost ghost closed this as completed May 19, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant