Manual:Image administration/ro

Acest articol descrie modul în care MediaWiki gestionează și stochează fișierele, și oferă câteva informații despre configurare.

Acest lucru se aplică atât imaginilor cât și oricărui alt tip de fișier care poate fi încărcat. Toate fișierele sunt stocate cu un articol corespunzător în spațiul de nume „Fișier:”. Înainte de MediaWiki 1.14, se folosea în schimb spațiul de nume „Image:”. „Imagine:” este încă păstrat ca alias pentru compatibilitate inversă.

Încărcarea și utilizarea imaginilor

Vezi Help:Images

Activează încărcarea imaginilor

Pentru a încărca fișiere, trebuie îndeplinite următoarele condiții:

  1. MediaWiki trebuie să aibă activate încărcările. Setați $wgEnableUploads la true.
  2. Tipul de fișier trebuie să fie permis. Mai multe informații: $wgFileExtensions.
  3. Utilizatorul trebuie să facă parte dintr-un grup cu dreptul de „încărcare”. În mod implicit, aceasta este acordată tuturor utilizatorilor conectați.

Încărcările se fac folosind Special:Upload.

Vezi Configuring file uploads, MIME type detection și Adding support for new filetypes

Parametri relevanți pentru gestionarea fișierelor

Acești parametri sunt relevanți:

Miniatură imagine

Sintaxa imagini din MediaWiki permite redimensionarea dinamică și miniaturarea a imaginilor (consultați Manual:Configuring file uploads pentru ajutor general privind încărcarea fișierelor).

Miniaturile imaginilor necesită fie ImageMagick, fie GD library – niciuna dintre ele nu face parte din instalarea implicită MediaWiki.

GD

PHP vine cu librăria grafică GD activată în mod implicit. GD nu va necesita nicio configurare sau modificare pentru a fi utilizat.

Se recomandă utilizarea GD pe sistemele Windows.

GD poate fi descărcat de pe https://libgd.github.io/. În versiunile recente de PHP acest lucru nu este necesar.

ImageMagick

În MediaWiki, activați ImageMagick în LocalSettings.php setând $wgUseImageMagick la true.

ImageMagick poate fi descărcat de pe https://imagemagick.org/.

După ce ImageMagick este instalat, trebuie să activați ImageMagick și să direcționați MediaWiki către programul convert sau convert.exe de pe computerul dumneavoastră în LocalSettings.php, astfel:

$wgUseImageMagick = true;
#$wgImageMagickConvertCommand = 'C:/ImageMagick/convert.exe'; # for Windows
$wgImageMagickConvertCommand = '/usr/bin/convert'; # for Linux

Dacă folosești ImageMagick, setează $wgUseImageMagick la true în LocalSettings.php. Asigurați-vă că comanda este executabilă de procesul serverului web. De exemplu, utilizatorii de Windows vor dori să schimbe setările implicite la „C:\ImageMagick\convert.exe” (sau similar).

Pentru a recrea fișierele miniatură vechi, înainte de a utiliza ImageMagick, puteți utiliza $wgThumbnailEpoch.

Dacă randarea eșuează silențios, verificați și măriți $wgMaxShellMemory.

Consultați pagina de ajutor despre Miniaturi de imagini nu funcționează pentru depanare.

GraphicsMagick poate fi folosit și ca alternativă la ImageMagick. Va trebui să setați $wgCustomConvertCommand la următoarele. De exemplu:

$wgUseImageMagick = false;
$wgCustomConvertCommand = "gm convert %s -resize %wx%h %d";

libvips

MediaWiki core does not support libvips but there are extensions that let use this image processing library.


Formate de imagine

GIF

Pentru a vizualiza miniaturi ale fișierelor GIF „Animații” în Windows, trebuie să instalați ImageMagick așa cum este descris mai sus.

SVG

Prezentarea Wikimania 2016 despre SVG dinamic

MediaWiki acceptă randarea imaginilor SVG: dacă este activată, imaginile SVG pot fi utilizate ca alte fișiere de imagine — acestea vor fi redate automat ca fișier PNG și miniaturizate după cum este necesar. Dacă te afli pe o gazdă partajată și nu este preinstalat niciun renderer SVG, probabil ar trebui să ceri furnizorului tău să îl instaleze pentru tine.

Pentru a activa suportul SVG:

  1. Permiteți încărcarea fișierelor SVG în fișierul LocalSettings.php: $wgFileExtensions[] = 'svg';. Rețineți că MediaWiki va refuza fișierele SVG care conțin JavaScript, din motive de securitate.
    Dacă primiți o eroare care indică faptul că fișierul este corupt, asigurați-vă că detectarea tipului MIME funcționează corect.
  2. Adăugați $wgSVGConverter la LocalSettings.php și setați rendererul pe care doriți să îl utilizați.
    Opțiunile disponibile sunt ImageMagick, ImagickExt, sodipodi, inkscape, batik, rsvg și imgserv.
    De exemplu: $wgSVGConverter = 'ImageMagick';
    • Dacă programul de conversie nu se află în calea sistemului, trebuie să specificați „directorul” care conține programul folosind $wgSVGConverterPath .
    • librsvg este rapid, dar nu foarte precis. Depinde de un număr mare de biblioteci. Pentru a instala automat toate aceste biblioteci, este posibil să doriți să utilizați un manager de pachete. Proiectele Wikimedia folosesc rsvg.
    • Apache Batik anti-aliasing este uneori suboptimal. Analiza SVG este mai strictă, ceea ce îl face să respingă fișierele SVG „aproape valide” pe care le acceptă alte programe de redare (de exemplu, commons:File:UbuntuCoF.svg). Batik se bazează pe Java și este mult mai lent decât rsvg, deși acest lucru s-ar putea să nu fie o problemă majoră decât dacă adăugați constant fișiere SVG. Vezi SVG benchmarks. Necesită multă muncă pentru a funcționa, dacă nu este inclus în distribuția ta.
    • Inkscape face și el o treabă precisă cu SVG-uri, la jumătate din viteza rsvg, dar a fost conceput pentru utilizare grafică interactivă; cu toate acestea, vine cu inkview, care este un program de vizualizare/conversie – necesită un director principal în care se poate scrie pentru utilizatorul care rulează. 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 — use only if it's in your distribution or available as a complete standalone package.
    • Sodipodi is the program Inkscape was forked from.

The same considerations apply. Sodipod is no longer under active development.

    • ImageMagick is the default but its rendering works imperfectly; avoid it if possible.
      • 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 $wgSVGConverters['ImageMagick'] = '"' . $wgImageMagickConvertCommand . '" -background white -thumbnail $widthx$height^! $input PNG:$output';, which also allows for spaces in the path.
      • To prevent thumbnail creation errors with ImageMagick, if it's ≥ 7.0.9-25, then Inkscape must also be ≥ 1.x.x. Likewise, if ImageMagick is < 7.0.9-25, then Inkscape must also be < 1.x.x.

See ImageMagick issue.

    • The PHP Imagick extension supports SVG rendering, however the same considerations as for the regular ImageMagick apply.
    • 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.

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.

Troubleshooting

If you see a blank square instead of SVG (Chrome) or no image at all (Firefox) and all PNG links lead to 404 error and you don't see any other error message anywhere please check $wgGenerateThumbnailOnParse variable. Setting it to false may make SVG transformation deferred always. Make sure that proc_open and symlink PHP methods are enabled (they may be disabled in php.ini for security or performance reasons).


JPEG (using GD)

Simply adding the following line to LocalSettings.php will cause auto fall back to the GD library:

$wgUseImageMagick = false;

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';

  1. Add $wgTiffThumbnailType to LocalSettings.php and set to either jpg or png to specify which type of thumbnail you wish to have generated.
  1. Making thumbnails of TIFF files may require system resources beyond those needed for thumbnailing JPEG, GIF, or PNG files.

Consider appropriate settings for $wgMaxImageArea and $wgMaxShellMemory

DjVu

Deletion of images

Files, like wiki pages, can only be deleted by users with the Șterge pagini (delete) permission (administratori by default). Deletion of files is done by deleting the associated description page (or by clicking the șterge tot link in the Istoricul fișierului table).

Deletion of individual revisions

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 ștergere 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 oldimage table while information on old revisions of the pages are stored in the revision table.

Undeleting files

Files can be undeleted in exactly the same way as normal wiki pages. The directory in which deleted files are stored is defined by Manual:$wgDeletedDirectory. 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 eraseArchivedFile.php maintenance script. If you want to delete all of them completely, you can do that with the deleteArchivedFiles.php 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.

Modifying the display of file pages

MediaWiki:Filepage.css is a standard stylesheet which can be used to modify the display of file pages. The contents of Filepage.css will be loaded only on File namespace pages. If remote files are enabled, the remote wiki's version of this page will also load.

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.

  1. The file itself is stored in a folder on the file system with whitespaces merged and replaced with _.
  1. 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 $wgHashedUploadDirectory 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 $wgUploadPath (images/, 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 T11018, 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 Extension:Math or Manual:Math.
x/xy
If $wgHashedUploadDirectory is set to true (which is the default), images will be stored in subfolders of the images, thus making file paths look like images/a/ab/filename.jpg. See Manual:$wgHashedUploadDirectory 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 - Holds some metadata such as the size of the file and the upload date.
  • oldimage - This stores information for files that have been replaced with newer versions.
  • filearchive - Holds the information on the deleted files.
  • imagelinks - 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 20.778 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, 4 KB for the thumb directory, 64KB 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 (e.g. /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 Manual:Image authorization.

Upload form

Licensing

MediaWiki allows licenses to be added to files uploaded from the Special:Upload page. The list of licenses that appear in the license selection dropdown can be edited on the MediaWiki:Licenses page by a sysop.

The page should be a bulleted list of items, and can have sub-items. Each item can have one or more parameters, with the parameter separated by the pipe character (|).

To make headers/categories, use only one parameter in a list item. The text will be what appears in the dropdown list, and will appear greyed-out and unclickable.

To add license options, two or more parameters are required. The first parameter will be the template name to use, without the double square brackets. The last parameter will be what appears in the dropdown list for that license. Any additional parameters between the first and last parameters will be passed as arguments to the template. When a license is selected, a preview of what it would look like on the final page is shown in the upload wizard.

Below is a simple example (not using real templates) of how MediaWiki:Licenses should be formatted:

Work typeCoverageUsed template
Licence template selection for your work
Work without licence {{no-lic|No license.}}
Work made be me Used on this wiki {{self-lic|And it can only be used on this wiki.}}
Used anywhere {{self-lic|free=yes|And I allow it to be used anywhere.}}
Work made by someone else Work belongs to the public domain {{pd-lic|It's in the public domain.}}
Work is copyrighted {{copyright-lic|It's copyrighted.}}
Work is under a CreativeCommons license {{cc-lic|It uses some CreativeCommons license.}}
Work is under the CC-BY-SA license {{cc-lic|by-sa|It uses the CC-BY-SA license.}}

The above assumes each template ending in "-lic" exists, where some of those templates take positional arguments such as "by-sa" and others take named arguments such as "free=yes". Selecting the option "And I allow it to be used anywhere", for example, would add the following template call to the page of the new file:

{{self-lic|free=yes}}

Sites like Wikipedia and WikiMedia Commons will also use the subst: tag, such as WikiMedia Common's usage of it below:

** subst:Template 2|flickrreview|subst:uwl|Image from Flickr and I do not know the license

"Template 2" is an actual template that will take two parameters (being template names) and surround them with double curly brackets so they get transcluded on the page of the new image. "uwl" is a template, whose documentation requires using it with the "subst:" tag instead of directly. The above will result in the following being added to the uploaded file's page:

{{flickrreview}}{{subst:uwl}}

On Wikipedia, substitution is used in other ways, such as adding a timestamp with the license at the time of upload.

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.

Notes

  1. Wikimedia sites also do not rely on client-side rendering, despite a request to do so, T5593.
Category:MediaWiki configuration/ro#Image%20administration/ro Category:Upload/ro
Category:MediaWiki configuration/ro Category:Upload/ro