Extension:VipsScaler/fr

From Linux Web Expert

Manuel des extensions MediaWiki
VipsScaler
État de la version : stable
File:Screenshot of VipsScaler extension.png
Implémentation Média
Description Allows to scale PNG and JPEG images using VIPS
Auteur(s) Bryan Tong Minh (Bryantalk)
MediaWiki 1.19+
Modifie la base
de données
Non
Licence Aucune licence spécifiée
Téléchargement
README
Téléchargements trimestriels Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Utilisé par les wikis publics Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Traduire l’extension VipsScaler sur translatewiki.net si elle y est disponible
Problèmes Tâches ouvertes · Signaler un bogue

The VipsScaler extension is a wrapper around the free image processing software VIPS. VIPS is a set of image manipulation tools specially designed for speed and low memory usage. This is useful for resizing large PNGs, and it improves the appearance of shrunken JPEGs.

The extension shells out to the vips binary. It can be configured to scale only certain files (for example: big PNGs) by configuring $wgVipsOptions.

Install VIPS

Install VIPS. It can be downloaded from https://libvips.github.io/libvips or your OS repository (see below).

Debian / Ubuntu

$ apt-get install libvips-tools

If you want to build from source have a look at upstream documentation: https://libvips.github.io/libvips/install.html

(Wikimedia has packaged and uses a more recent version for Ubuntu 12.04 at apt.wikimedia.org)

Mac OS X

homebrew
brew install homebrew/science/vips
binary symlink is /usr/local/bin/vips

Install VipsScaler extension


  • Install VIPS (see above)
  • <translate> [[<tvar name=2>Special:ExtensionDistributor/VipsScaler/fr</tvar>|Download]] and move the extracted <tvar name=name>VipsScaler/fr</tvar> folder to your <tvar name=ext>extensions/</tvar> directory.</translate>
    <translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/VipsScaler%2Ffr
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    wfLoadExtension( 'VipsScaler/fr' );
    
  • Navigate to Special:VipsTest to verify it is working and see the difference in output quality.
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>

Configuration

$wgVipsCommand
path to the vips command (default: vips).
$wgVipsOptions
Options and conditions for images to be scaled with this scaler. Set to an array of arrays. The inner array contains a condition array, which contains a list of conditions that the image should pass for it to be scaled with vips. Conditions are mimeType, minArea, maxArea, minShrinkFactor, maxShrinkFactor. The other items in the array are options. Options available are:
  • sharpen - Set to an array with keys 'radius' and 'sigma', which are parameters to gaussian sharpen matrix.
  • preconvert - Convert the file to a .v file first, which costs some space, but saves memory on the actual downsize
  • bilinear - Use im_resize_linear instead of im_shrink
  • convolution - Apply specified convolution matrix
  • setcomment - Add an exif comment specifying the source of the file. Requires $wgExiv2Command to be set properly.
$wgVipsOptions = [
  // Sharpen jpeg files which are shrunk more than 1.2
  [
    'conditions' => [
      'mimeType' => 'image/jpeg',
      'minShrinkFactor' => 1.2,
    ],
    'sharpen' => [ 'radius' => 0, 'sigma' => 0.8 ],
  ],
  // Other jpeg files
  [
    'conditions' =>[
      'mimeType' => 'image/jpeg',
    ],
    'sharpen' => false,
    'bilinear' => true,
  ],
  // Do a simple shrink for PNGs
  [
    'conditions' => [
      'mimeType' => 'image/png',
    ],
  ],
];