public CmsJspImageBean createWidthVariation(String widthStr) {

        CmsJspImageBean result = null;

        try {

            double baseRatio;
            if ((getOriginalScaler().getFocalPoint() != null)
                && checkCropRegionContainsFocalPoint(getScaler(), getOriginalScaler().getFocalPoint())) {
                // We use scaling mode 8 if there is a focal point, and in this case,
                // the correct aspect ratio is width x height, not cropWidth x cropHeight
                // even if cropping is set
                baseRatio = (double)getScaler().getWidth() / (double)getScaler().getHeight();
            } else if (getScaler().isCropping()) {
                // use the image crop with/height for aspect ratio calculation
                baseRatio = (double)getScaler().getCropWidth() / (double)getScaler().getCropHeight();
            } else {
                // use the image original pixel width/height for aspect ratio calculation
                baseRatio = (double)getScaler().getWidth() / (double)getScaler().getHeight();
            }

            // height is not set, calculate it with the given width and the aspect ratio
            int targetWidth = Integer.valueOf(widthStr).intValue();
            int targetHeight = (int)Math.round(targetWidth / baseRatio);

            CmsImageScaler targetScaler = createVariation(
                getWidth(),
                getHeight(),
                getBaseScaler(),
                targetWidth,
                targetHeight,
                getQuality());

            if (targetScaler != null) {
                result = createVariation(targetScaler);
            }

        } catch (NumberFormatException e) {
            if (LOG.isWarnEnabled()) {
                LOG.warn(String.format("Illegal width format: '%s' not usable for image scaling", widthStr));
            }
        }

        return result;
    }
public CmsJspImageBean createWidthVariation ( String widthStr ) { CmsJspImageBean result = null ; try { double baseRatio ; if ( ( getOriginalScaler ( ) . getFocalPoint ( ) != null ) && checkCropRegionContainsFocalPoint ( getScaler ( ) , getOriginalScaler ( ) . getFocalPoint ( ) ) ) { baseRatio = ( double ) getScaler ( ) . getWidth ( ) / ( double ) getScaler ( ) . getHeight ( ) ; } else if ( getScaler ( ) . isCropping ( ) ) { baseRatio = ( double ) getScaler ( ) . getCropWidth ( ) / ( double ) getScaler ( ) . getCropHeight ( ) ; } else { baseRatio = ( double ) getScaler ( ) . getWidth ( ) / ( double ) getScaler ( ) . getHeight ( ) ; } int targetWidth = Integer . valueOf ( widthStr ) . intValue ( ) ; int targetHeight = ( int ) Math . round ( targetWidth / baseRatio ) ; CmsImageScaler targetScaler = createVariation ( getWidth ( ) , getHeight ( ) , getBaseScaler ( ) , targetWidth , targetHeight , getQuality ( ) ) ; if ( targetScaler != null ) { result = createVariation ( targetScaler ) ; } } catch ( NumberFormatException e ) { if ( LOG . isWarnEnabled ( ) ) { LOG . warn ( String . format ( "Illegal width format: '%s' not usable for image scaling" , widthStr ) ) ; } } return result ; }
Creates a width scaled version of the current image.<p>

@param widthStr the with variation to generate, for example "1078" or "800".<p>

@return a width scaled version of the current image