Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-3734

Preview in file upload control does not scale down perfectly square images

XMLWordPrintable

      When the image is perfectly square, like 600x600, its not scaled to fit inside the 150x150 area that the preview should fit into. The code is this, in DialogFile.java:

                          // resize if to big
                          if(imgwidth > imgheight && imgwidth > 150){
                              imgheight = (int)(150.0/imgwidth * imgheight);
                              imgwidth = 150;
                          }
                          else if(imgheight > imgwidth && imgheight > 150){
                              imgwidth = (int)(150.0/imgheight * imgwidth);
                              imgheight = 150;
                          }
      

      It should be fixable by changing to:

                          // resize if to big
                          if(imgwidth == imgheight && imgwidth > 150){
                              imgwidth = 150;
                              imgheight = 150;
                          } else if(imgwidth > imgheight && imgwidth > 150){
                              imgheight = (int)(150.0/imgwidth * imgheight);
                              imgwidth = 150;
                          }
                          else if(imgheight > imgwidth && imgheight > 150){
                              imgwidth = (int)(150.0/imgheight * imgwidth);
                              imgheight = 150;
                          }
      

      I've attached an image that can be used to demonstrate the problem.

        Acceptance criteria

              rkovarik Roman Kovařík
              tmattsson Tobias Mattsson
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Bug DoR
                  Task DoD