Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfscript>
- img = imageNew(
- source = "",
- width = 16,
- height = 2000,
- canvasColor = "ff3366"
- );
- width = imageGetWidth( img );
- height = imageGetHeight( img );
- boxSize = 100;
- // When scaling the image, whichever dimension has the largest magnitude becomes
- // our limiting factor. This is the magnitude that drives the proportional scaling.
- sizeConstraint = max( width, height );
- // We only need to resize the image if some part of it doesn't fit inside the box.
- if ( sizeConstraint > boxSize ) {
- // CAUTION: In earlier versions of Lucee, this will not work because the
- // proportional scaling of the image will cause the WIDTH to be LESS THAN 1. As
- // such, the underlying Java code will try to create a canvas of WIDTH = 0, which
- // is invalid.
- imageScaleToFit( img, boxSize, boxSize, "highestPerformance" );
- }
- imageWrite( img, "./output-scaled.png" );
- </cfscript>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement