scottcheng / cropit

A "customizable crop and zoom" jQuery plugin.
http://scottcheng.github.io/cropit/
MIT License
874 stars 304 forks source link

minZoom as a number? support negative values? #99

Open adispezio opened 9 years ago

adispezio commented 9 years ago

Hey there. Fantastic plugin - thank you.

I love the way that maxZoom works and was wondering if minZoom could support the same approach of using a scale value. For example, if freeMove is true, it would be cool if minZoom could support a negative number.

The use case is I'm trying to make the image smaller than the preview area (so the background of the preview area is visible).

minzoom

I realize this defeats the purpose of cropping an image, but it seems like most of the pieces are there to accomplish this.

scottcheng commented 9 years ago

I may be wrong but I feel like that's quite a rare use case that you'd want the image to be smaller than the output. One major concern with adding a numeric minZoom is that, if the original size of the image * minZoom is still larger than the preview, it can be confusing whether the image should be able to zoom down to the preview area (resulting in a zoom smaller than specified minZoom) or only down to minZoom. I'd prefer to keep it the way it is unless there's a compelling use case for what you suggested.

anand-clarion commented 8 years ago

Hi scottcheng I extremly need the same feature so is there any way to achieve that with cropit? Thanks

waqarit commented 8 years ago

I also want the same feature. Please help as soon as possible. I want to set initial zoom to center.

gijsjager commented 8 years ago

I totally agree with the adispezio.

My client has a lot of logo's he wants to align in a square canvas without the logo touching the borders. This is only possible with a negative minZoom.

I am going to check if its possible to extend this. But it would be nice if it would be an option in this plugin. Because all the other parts are just great!

@edit

I have edited the following line 921: if (minZoom === 'fit') { this.minZoom = Math.min(widthRatio, heightRatio); } else if( minZoom === 'fill' ) { this.minZoom = Math.max(widthRatio, heightRatio); } else { this.minZoom = Math.min(widthRatio, heightRatio) / minZoom; }

This makes it possible to add numeric value to the minZoom option. Where the number is a multiplier how much smaller the image can be than the minimum value of the image. Example: { minZoom: 2 } => makes it possible that the image can be more than 2 times smaller than normal.

Maybe this helps someone else.

callumalden commented 7 years ago

This is really helpful. A further thought- is it possible to do some math on $imageCropper.cropit('imageSize'); to calculate the PPI of the image/

My dropit.js canvas size is calculated from user defined size in inches, which I display once doing the calculation 10" = 3000pixels (that's a canvas of effectively 300PPI).

I'm using this as part of a print-preview.