Changeset 2933


Ignore:
Timestamp:
Aug 26, 2012, 8:22:16 PM (8 years ago)
Author:
nosdeputes
Message:

affreux masi regle le souci de décalage du survol sur les machines avec imagemagick qui galère

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpc/trunk/project/apps/frontend/modules/circonscription/actions/actions.class.php

    r2863 r2933  
    149149   * If only one of $w and $h is given, preserve the svg ratio.
    150150   */
    151   private static function compute_areas($dom, $w, $h, $regexp, $deptitle = 0)
     151  private static function compute_areas($dom, $w, $h, $regexp, $deptitle = 0, $circo=false)
    152152  {
    153153    $areas = "";
     
    157157    $svg_w = (string) $svg->getAttribute('width');
    158158    $svg_h = (string) $svg->getAttribute('height');
     159
     160    if ($circo) {
     161      $svg_w = $svg_w / 5;
     162      $svg_h = $svg_h / 5;
     163    }
    159164
    160165    if ($w == 0 && $h == 0)
     
    241246    $y_max = max($maxy) + $margin;
    242247
    243     $svg->setAttribute('width', $x_max - $x_min);
    244     $svg->setAttribute('height', $y_max - $y_min);
     248    $svg->setAttribute('width', 5*($x_max - $x_min));
     249    $svg->setAttribute('height', 5*($y_max - $y_min));
     250    $svg->setAttribute('viewBox', $x_min." ".$y_min." ".($x_max - $x_min)." ".($y_max - $y_min));
    245251    $svg->setAttribute('transform', "translate(".-$x_min.",".-$y_min.")");
    246252  }
     
    282288    $im->setResolution($w * $x_ratio, $h * $y_ratio);
    283289    $im->readImageBlob($dom->saveXML());
    284 
     290    $im->resizeImage($w, $h, imagick::FILTER_LANCZOS, 0.9, true);
    285291    $im->setImageFormat("png");
    286292    echo $im;
     
    312318      $regexp = "/^$circo-(0[1-9]|[1-9]\d)$/";
    313319
    314     return array($dom, self::compute_areas($dom, $w, $h, $regexp));
     320    return array($dom, self::compute_areas($dom, $w, $h, $regexp, 0, true));
    315321  }
    316322
     
    349355    $w = $r['w'];
    350356    $h = $r['h'];
     357   
     358    $svg = $dom->getElementsByTagName('svg')->item(0);
     359    $svg->removeAttribute('transform');
    351360
    352361    $im = new Imagick();
     
    358367    $im->setResolution($w * $x_ratio, $h * $y_ratio);
    359368    $im->readImageBlob($dom->saveXML());
    360 
     369    $im->resizeImage($w, $h, imagick::FILTER_LANCZOS, 0.9, true);
    361370    $im->setImageFormat("png");
    362371    echo $im;
Note: See TracChangeset for help on using the changeset viewer.