Jump to content

Topic on Project:Support desk/Flow

ImageMagick ignores real max width of image

5
Netsu (talkcontribs)
88.130.123.155 (talkcontribs)

Intended behaviour. ;-)

Netsu (talkcontribs)

lol with GD similar behaviour. It is because I'm not specify option thumb

[[Файл:Tabulat.jpg|900px|thumb]] in image attr "width" = real width (836px)

[[Файл:Tabulat.jpg|900px]] in image attr width="900px"

I don't understand why someone need to show image with dimensions more than original. Interesting how developers explain this functional.

88.130.123.155 (talkcontribs)

There are several use cases for upscaling. I am sure you could also do some upscaling with GDlib or ImageMagick, but it won't improve quality either. ;-)

Netsu (talkcontribs)

fixed lol

  $("img").each(function(){

    var img = $(this);
    var pic_real_width, pic_real_height;

    $("<img/>") // Make in memory copy of image to avoid css issues
      .attr("src", $(img).attr("src"))
      .load(function() {

        pic_real_width = this.width;   // Note: $(this).width() will not
        pic_real_height = this.height; // work for in memory images.

        if (pic_real_width > 810) {

          pic_cur_height = Math.floor((pic_real_height * 810) / pic_real_width);
          pic_cur_width = 810;

        } else if ($(img).attr("width") > pic_real_width) {

          pic_cur_width = pic_real_width;
          pic_cur_height = pic_real_height;

        } else return true;

        $(img).attr("width", pic_cur_width);
        $(img).attr("height", pic_cur_height);

      });

  });