Manual:Image administration/fr

Cet article décrit comment MediaWiki manipule et stocke les fichiers, et donne des informations de configuration.

Il s'applique aux images aussi bien qu'à tous les autres types de fichiers qui peuvent être téléversés. Tous les fichiers sont stockés avec un article qui leur correspond dans l'espace de noms "Fichier:". Dans les versions antérieures à MediaWiki 1.14, l'espace de noms "Image:" était utilisé à la place. "Image:" est toujours conservé en tant qu'alias dans un but de rétrocompatibilité.

Téléversement et utilisation des images
Voir

Activation du téléversement des images
Pour téléverser des images, ces conditions doivent être réunies:


 * 1) MediaWiki doit avoir les téléversements activés. Paramétrer  sur 'true'.
 * 2) Le type de fichier doit être autorisé. Pour plus d'informations:.
 * 3) L'utilisateur doit appartenir à un groupe qui détient les droits de téléversement. Par défaut, ils sont alloués à tous les utilisateurs logués.

Les téléversements se font en utilisant Special:Upload.

Voir, 

Paramètres pertinents pour la manipulation des fichiers
Ces paramètres sont pertinents:



Miniaturisation des images
La syntaxe étendue pour les images (en) autorise les images à être automatiquement affichées en miniatures (voir Manual:Configuring file uploads pour de l'aide concernant le téléversement).

La mise en miniature d'une image nécessite soit ImageMagick soit GD library - aucun des deux ne sont inclus par défaut dans l'installation de MediaWiki, bien que certaines versions de PHP incluent GD. ImageMagick est recommandé si une meilleure qualité des miniatures est requise; il peut être téléchargé depuis imagemagick.org. GD est inclus dans certaines versions de PHP, et il est recommandé d'utiliser GD pour les systèmes Windows. Un téléchargement direct de GD est disponible depuis LibGD GitHub.

Pour les versions plus anciennes de MediaWiki (antérieures à 1.10.0), paramétrez sur 'true' pour activer la miniaturisation. Pour les version plus récentes, ce n'est pas nécessaire.

Si vous utilisez ImageMagick, paramétrez sur 'true' dans le fichier LocalSettings.php. Vérifiez que la variable pointe vers le lien (absolu) de la commande de conversion de votre installation et que la commande est exécutable par le processus web du serveur. Par exemple, les utilisateurs de Windows devront changer la valeur par défaut par "C:\ImageMagick\convert.exe" (ou similaire).

Pour recréer les anciens fichiers de miniatures qui existaient avant que vous utilisiez ImageMagick, vous pouvez utiliser.

Si le rendu des images ne s'actualise pas, vérifiez la variable et augmentez sa valeur.

GraphicsMagick peut maintenant aussi être utilisé comme alternative à ImageMagick. Vous aurez besoin de paramétrer la variable $wgImageMagickConvertCommand avec le lien (absolu) vers la commande 'gm'. Ex.:

$wgImageMagickConvertCommand = "/usr/bin/gm";

GIF
Pour mettre en miniature les animations GIF sous Windows, vous devrez installer ImageMagick comme décrit plus haut.

SVG
MediaWiki supporte l'affichage des images SVG: lorsqu'elle sont activées, les images SVG peuvent être utilisées comme les autres fichiers image - elles seront automatiquement affichées comme des fichier PNG et miniaturisées si besoin. Si vous utilisez un hébergement mutualisé et qu'aucun module d'affichage n'est préinstallé, vous devrez probablement demander à votre hébergeur de l'installer pour vous.

Pour activer le support SVG:


 * 1) Autoriser le téléversement de fichiers SVG dans le fichier LocalSettings.php: $wgFileExtensions[] = 'svg'; Notez que MediaWiki refusera les fichiers SVG qui contiennent du JavaScript, pour des raisons de sécurité.
 * Pour éviter un faux positif, ajoutez la valeur  au fichier.
 * Si une erreur concernant le fait que le fichier est corrompu est renvoyée, vérifiez que l'identification du format de données MIME fonctionne correctement.
 * 1) Ajoutez la valeur   à  et paramétrez le module d'affichage que vous souhaitez utiliser.
 * Les options disponibles sont ImageMagick, ImagickExt , sodipodi , inkscape , batik , rsvg , et imgserv.
 * Par exemple: $wgSVGConverter = 'ImageMagick';
 * 1) * Si le programme de conversion n'est pas dans le chemin d'accès système, vous devez spécifier le "répertoire" qui contient le programme qui utilise ..
 * 2) * librsvg is fast but not very accurate. It has a ridiculously large chain of dependencies, so you may not want to bother unless you have a repository that includes it and resolves the dependencies for you. The Wikimedia projects use rsvg.
 * 3) * Batik is the most accurate SVG renderer available, although its anti-aliasing is sometimes suboptimal. Its SVG parsing is more strict, causing it to reject "almost valid" SVG files that other renderers accept (e.g. commons:File:UbuntuCoF.svg). Batik relies on Java, and is much slower than rsvg, though this may not be a huge issue unless you're constantly adding SVG files. See SVG benchmarks. Requires a lot of work to get running, if not included in your distribution.
 * 4) * Inkscape also does an accurate job of SVGs, half the speed of rsvg, but was designed for interactive graphical use; however, it comes with inkview which is a viewer/converter program - it requires a writable home directory for the user it's run as. Since it will be running as user www or something similar, it will try to create .inkscape/ and .gnome2/ directories in the corresponding home directory, and will fail silently, crash or hang indefinitely if it is not able to. Inkscape is preferable to rsvg (a) on Windows (it comes as a standalone package) or (b) if you have important SVGs drawn in Inkscape that do not render correctly in rsvg. Inkscape has as complicated a dependency chain as librsvg &mdash; use only if it's in your distribution or available as a complete standalone package.
 * 5) * Sodipodi is the program Inkscape was forked from. The same considerations apply. Sodipod is no longer under active development.
 * 6) * Since version 6.x.x ImageMagick renders SVGs, but imperfectly. This is the default, but avoid it if possible. However, it does work. On Windows, $wgConvertPath must be set to avoid a conflict with Windows' own convert.exe. One simple alternative in this scenario is to add to LocalSettings.php the line, which also allows for spaces in the path.
 * 7) * The PHP Imagick extension supports SVG rendering, however the same considerations as for the regular ImageMagick apply.
 * 8) * The GD library is not capable of converting SVG images to the PNG format, at least according to Joen Asmussen's June 2008 NoScope blog.
 * 9) * Most current web browsers except Internet Explorer (until version 9) can display SVGs directly. Using librsvg to render SVGs to a PNG will give much more accurate results, as well as less bandwidth consumption. Direct SVG display is not supported in MediaWiki by default, unless you install NativeSvgHandler extension.

Set $wgSVGConverter = false if SVG rendering is not needed and you wish to make your users download the svg file in order to view it.

JPEG (using GD)
Simply add the following line to LocalSetting.php, this will cause auto fall back to GD library.

For errors with JPEG thumbnails, see JPEG (using GD).

TIFF
Generating thumbnails of TIFF files requires MediaWiki 1.15.0 or newer.


 * 1) Allow upload of TIFF files in the LocalSettings.php file: $wgFileExtensions[] = 'tif';
 * 2) Add $wgTiffThumbnailType to LocalSettings.php and set to either jpg or png to specify which type of thumbnail you wish to have generated.
 * 3) Making thumbnails of TIFF files may require system resources beyond those needed for thumbnailing JPEG, GIF, or PNG files. Consider appropriate settings for $wgMaxImageArea</tt> and $wgMaxShellMemory</tt>

Deletion of images
Files, like wiki pages, can only be deleted by users with the " (delete)" permission ( by default). Deletion of files is done by deleting the associated description page (or by clicking the "" link in the "" table).

Deletion of individual revision
If a file has been altered, there is a revision history of the files which is displayed on the file article page. Each revision has a "" link. If this is clicked, the revision and the file are deleted.

The versions of files are separate from the page history of the file description page.

Information about old revisions of files are stored in the table while information on old revisions of the pages are stored in the  table.

Undeleting files
Before MediaWiki version 1.8, deleted images/files can not be undeleted (only the associated description page can be restored).

From MediaWiki version 1.8 up to 1.10, archiving deleted images/files (and thus undeleting them) is disabled per default, but can be enabled by setting $wgSaveDeletedFiles = true.

Since MediaWiki version 1.11, this is enabled per default, and $wgSaveDeletedFiles is deprecated. Instead, the behavior is controlled by.

Information about deleted images are stored in the filearchive table.

Deletion of Archived Files
Since MediaWiki version 1.11, deleted images are still stored on the server by default. If you want to delete selected archived images, you can do so using the maintenance script. If you want to delete all of them completely, you can do that with the script. If you delete archived files, you can not undelete those files anymore.

Reasons for Deleting a File
When choosing to delete a file, as described above, users will be asked to provide a reason for deletion. The available reasons can be edited on the MediaWiki:Filedelete-reason-dropdown of your wiki.

Data storage
Whenever an image is uploaded, several things are created:


 * 1) An article in the file namespace with the name of the file, e.g. File:MyPicture.png. This page is stored and can be edited like any other page.
 * 2) The file itself is stored in a folder on the file system.
 * 3) If necessary and thumbnailing is available, thumbnailed versions of the file will be created when necessary (such as for the usage on the file description page. These are stored in the thumb directory of the image directory, in a separate directory for each main file.

If is enabled (by default), MediaWiki creates several subdirectories in the images directory.

The directory names are from the first two characters of the md5 hash of the final filename.

Folders
All image files are stored in a folder determined by (, by default).

Description of named image subfolders:


 * archive: This is the storage place for files that have been replaced by newer versions.
 * temp: used for temporary storage of files during image uploading. (Due to, these files may not always be automatically deleted)
 * thumb: Thumbnails (automatically generated) for the files. If these are deleted, they are automatically regenerated when needed.

Depending on the configuration, there may be additional image subfolders:
 * math: Folder to store your rendered TeX input, see also Manual:Enable TeX or Math.
 * x/xy: If  is set to true (which is the default), images will be stored in subfolders of the images, thus making file paths look like  . See  for more details on why this might be desired and how this system works.

Database tables

 * The file description page is stored as any page in the page, text, revision etc. tables
 * image table: Holds some metadata such as the size of the file and the upload date.
 * oldimage table: This is stores information for files that have been replaced with newer versions.
 * filearchive table: holds the information on the deleted files.
 * imagelinks table: Records what pages use a file.

Space usage
Files need considerably more space than articles. The following calculations assume a block size of 4KB with Linux/Unix servers.

The default setting is $wgHashedUploadDirectory = true.

Space requirements for all directories:


 * image directories: 0-f/x0-f: max. 16*16 = 256 directories = 256*4 KB = 1024 KB
 * archive directories: 0-f/x0-f: max. 16*16 = 256 directories = 256*4 KB = 1024 KB
 * thumb directories: 0-f/x0-f: max. 16*16 = 256 directories = 256*4 KB = 1024 KB
 * temp directories: 0-f/x0-f: max. 16*16 = 256 directories = 256*4 KB = 1024 KB

Therefore, the basic amount of space needed without any images uploaded is 4 MB in theory (although the directories are created only when needed).

For each file we need:
 * size of the original image file + 2 KB average overhead

For files that need to be thumbnailed:
 * size of the created thumbnail(s) + 2 KB average overhead (each)
 * directory for thumbnail (4KB) (each image has its own thumbnail directory)

Examples:
 * image 20778 Byte png (small size, no thumb): 24 KB for the image: Total 24 KB
 * image 123.000 Byte jpeg (big size, auto thumb): 124 KB for the image, 4KB for the thumb directory, 64 KB for the thumb: Total: 192 KB

File Access
Uploaded files are generally served directly by the web server, not through MediaWiki. While there may be a minimal level of security through obscurity with path encryption (eg. /c/c4/...) if $wgHashedUploadDirectory is set, the path can be calculated easily from the file name and does not provide true protection.

For limiting access to authorized users, see Image Authorization

Licensing
A feature of MediaWiki allows the Special:Upload Page to streamline licensing of images. Wikipedia's Upload Page has a Licensing drop down box below image summary. This feature is turned off in default MediaWiki. To turn this feature on a sysop needs to edit Licenses in the MediaWiki namespace (example: MediaWiki:Licenses). S/he can do this by going to the MediaWiki:Licenses page of their wiki and clicking 'create' or 'edit'.

The page MediaWiki:Licenses expects a certain format in a wiki list.

Line 1 will produce "License text" and substitute the license 1 template in the image page and transclude license 2.

Line 2 will show a greyed out header with text "Header 1:"

Line 3 will produce "Attribution ShareAlike 2.5" and transclude template cc-by-sa-2.5 on the image page.

For detailed real world example, see Wikipedia:MediaWiki:Licenses or Commons:MediaWiki:Licenses.

Foreign Repositories
It is possible to access files stored in foreign repositories, without needing to upload them to the wiki, by setting the $wgForeignFileRepos array. This feature offers several possibilities:
 * ForeignAPIRepo accesses files from a remote MediaWiki installation, such as Wikimedia Commons, through its API
 * ForeignDBRepo accesses files through a database, and is useful for creating wiki families
 * FSRepo accesses files from a local folder

In all cases, one would be able to embed files into a page using ordinary image syntax and specifying the name of the file in the foreign repository. Note that some of the above implementations are still experimental, and might not be suitable for production sites.

MediaWiki Version
This applies to:
 * MediaWiki 1.9.x and above
 * other versions not verified