Project

General

Profile

« Previous | Next » 

Revision 896e7ef8

Added by Andreas Kohlbecker almost 4 years ago

ref #9134 fixing calculation of croped thumbnail images and adding tests

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/media/MediaUriTransformationProcessor.java
197 197
        } else if (originalWidth == null || originalHeight == null) {
198 198
            return new Point(trans.getWidth(), trans.getHeight());
199 199
        } else {
200
            // calculate
201
            float originalAspectRatio = ((float) originalWidth / (float) originalHeight);
202

  
203
            boolean widthIsLimiting = trans.getHeight() == null ||
204
                    trans.getWidth() != null && trans.getHeight() * originalAspectRatio > trans.getWidth() ;
205
            if (widthIsLimiting){
206
                return new Point(trans.getWidth(), Math.round(trans.getWidth() / originalAspectRatio ));
200
            if(trans.getHeight() != null && trans.getWidth() != null && !trans.getHeight().equals(trans.getWidth())) {
201
                return new Point(trans.getWidth(), trans.getHeight());
207 202
            } else {
208
                return new Point(Math.round(trans.getHeight() * originalAspectRatio), trans.getHeight());
203
                // calculate
204
                float originalAspectRatio = ((float) originalWidth / (float) originalHeight);
205

  
206
                boolean widthIsLimiting = trans.getHeight() == null ||
207
                        trans.getWidth() != null && trans.getHeight() * originalAspectRatio > trans.getWidth() ;
208
                if (widthIsLimiting){
209
                    return new Point(trans.getWidth(), Math.round(trans.getWidth() / originalAspectRatio ));
210
                } else {
211
                    return new Point(Math.round(trans.getHeight() * originalAspectRatio), trans.getHeight());
212
                }
209 213
            }
210 214
        }
211 215
    }

Also available in: Unified diff