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

Added resizeToFit and cropToAspectRatio methods #37

Merged
merged 3 commits into from
Aug 1, 2014
Merged

Added resizeToFit and cropToAspectRatio methods #37

merged 3 commits into from
Aug 1, 2014

Conversation

jasny
Copy link
Contributor

@jasny jasny commented Mar 4, 2014

Added 2 methods:

  • ImageWorkshopLayer::resizeToFit() resizes an image to fit a bounding box.
  • ImageWorkshopLayer::cropToAspectRatio() crops either to width or height of the document to match the aspect ratio.

Example usage of resizeToFit()

// Shrink the image so the width is <= 150px and the height <= 200px, maintaining the aspect ratio
$pic->resizeToFitinPixel(150, 200);
  • If the original image is 300x250, the new image will be 150x100.
  • If the original image is 200x400, the new image will be 100x200.
  • If the original image is 100x100, the new image will be 100x100.

Example usage of cropToAspectRatio()

// Crop picture to 4:3 aspect ratio, cropping from the center
$pic->cropToAspectRatioInPercent(4, 3, 50, 50);

// Crop and resize the image to be exactly 100x100 pixels
$pic->cropToAspectRatioInPercent(1, 1, 50, 50); // Square
$pic->resizeInPixel(100, 100);

This methods resizes an image to fit a bounding box.
This methods crop either to width or height of the document to match the aspect ratio.
50% should mean the middle of the picture.
Sybio added a commit that referenced this pull request Aug 1, 2014
Added resizeToFit and cropToAspectRatio methods
@Sybio Sybio merged commit acdd662 into Sybio:master Aug 1, 2014
@jasny jasny deleted the additional_resizing branch August 1, 2014 13:18
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

Successfully merging this pull request may close these issues.

None yet

2 participants