Posted by aacraig on November 7, 2009 at 8:31am
Jump to:
| Project: | Imagefield Crop |
| Version: | 6.x-1.0-beta3 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
I would like to impose a height for a cropped image, but allow the user to set their own width on the crop.
The current implementation only allows for no restraint or restraining height and width together.
Comments
#1
+1
This would be a great addition.
#2
+1 This would be an interesting feature.
#3
Can you present us the example use case for this request? It may get more interest if someone understands why this would be useful.
#4
Have a look at http://www.appleandolive.com/
In the photo wall on the left of the page, all of the images are the same dimensions. This is due to this limitation in image cropping. I would like to make it so that the client could crop their image to an arbitrary width depending on the photo, but constrain the crop to the fixed height, so that it doesn't ruin the design.
I'm sure the same case for arbitrary vertical cropping also exists in the wild :)
#5
+1 subscribing
Design wise, I believe having this feature will be very beneficial as you have more control over the size/placement of the image and crop preview windows on the node edit page to fit the design of the page.
#6
Here's an example use case: You have a design based on a grid, and you're using the Insert module to place images in the body of your content, floated, with text flowing around the image. So you want to ensure that any image placed in the content aligns to the grid by constraining the width to a fixed number of pixels (so it spans the desired number of grid columns). But you'd like to allow the person uploading the photo the flexibility to crop it to whatever height looks best.
At least, that's why I wanted this feature!
#7
+1 subscribing
I need this for a design where the widths need to be fixed but not the height.
I'm not sure if you would really need to write the code for this so much as just have a place to process the file through an ImageCache preset which would handle the sizing.
#8
+1 subscribing
#9
+1. Another use-case is a blog site. For some designs, the width of images uploaded to the blog (like the main blog photo) is always a fixed width to keep consistency, but the height can vary and grow with the page (since blogs grow vertically so a taller photo won't break the design).
Like this for example: http://www.inhabitat.com/
#10
Would anyone with programming skills be able to kindly create a patch for review?
Your help would be very much appreciated. Thank you!
#11
kindly bumping
#12
me too. I would like to have a limit on the width of a photo, and enforce that, but allow the height to vary, to accommodate vertical images. Thanks.
#13
Another vote for this feature.
I created another related design request for a "Background Option" that would allow us to set a background color so if the image uploaded is quite small; you can still fit it within any desired output resolution.
http://drupal.org/node/851000
And likewise, if the image uploaded is too big - with a background layer you would theoretically have the potential to add a scaling feature; so if a user uploaded an image that had extremely large width - they could scale it down (proportionally) to fit within your set output resolution - and the background layer would fill out the remaining height.
#14
+1, would make a lot of use of this feature
#15
To do that you need to replace the line 191 of the file imageapi/imageapi.module ($scale = max($width / $image->info['width'], $height / $image->info['height']);) by the following code:
if ($height <= 0) {$scale = ($width / $image->info['width']);
$height = ($image->info['height'] * $scale);
}
else if ($width <= 0) {
$scale = ($height / $image->info['height']);
$width = ($image->info['width'] * $scale);
}
else {
$scale = max($width / $image->info['width'], $height / $image->info['height']);
}
Then if you want to have a fixed width of 400px and variable height, you need to create a "Scale And Crop" action and set width to 400 and height to 0.
#16
+1 - This would be great.
#17
Subscribing
#18
+1, I also have a requirement for this type of feature.
#19
+1 o also need this feature
#20
#15 worked for me, thanks. Would be great if it didn't have to be tied to an action/trigger, but better than nothing.