CropTool is a tool for cropping image files at Wikimedia Commons and other Wikimedia sites using the MediaWiki API with OAuth. Help page on Commons.
- Supports JPEG, PNG and (animated) GIF files, and also single pages from DJVU and PDF files.
- JPEGs can be cropped either losslessly using jpegtran or pixel perfect using ImageMagick.
- Detects
{{Remove border}}, Category:Images with borders and{{Watermark}}, and provides check boxes for optional removal of these upon cropping. - The result can replace the original file or be uploaded as a new one.
- If the result is uploaded as a new file on Wikimedia Commons,
- the
{{Extracted from}}template is added to the new file, and the{{Image extracted}}template is added or updated on the original. - some templates are not copied to the new page: quality assessment templates ([Featured picture](https://commons.wikimedia.org/wiki/Template:Featured picture), Valued image, Quality image, Picture of the day, Assessments), license review templates and crop tracking templates (Extracted from and Image extracted).
- the
- Stops users from cropping images waiting for license review (having
{{Flickrreview}}without any parameters, or some of theUser:FlickreviewRsubtemplates), since images should be reviewed before being altered.
The easiest way to setup a development environment is by using Vagrant. If you have Vagrant installed, just type
vagrant up
This will create a virtual machine with the static IP 172.28.128.4 (you can change this in the Vagrantfile if needed). To test the MediaWiki OAuth authentication, you can redirect tools.wmflabs.org to your newly created virtualbox machine by adding an entry to your /etc/hosts file:
172.28.128.4 tools.wmflabs.org
If you then visit https://tools.wmflabs.org/croptool in your browser, the content will be fetched from your virtualbox machine. The Vagrant provisioner has generated a self-signed certificate, so https will work, but the browser will of course warn you about the certificate being self-signed.
Of course you need to remember to remove the entry from /etc/hosts when you're done testing.
As a lightweight alternative for a development environment, we provide a Caddyfile which is meant to be used with Caddy. This allows to do frontend development without the need to boot a virtual machine.
- Run
caddyin the source directory - Add
127.0.0.1 tools.wmflabs.orgto your/etc/hosts - Open https://tools.wmflabs.org:7890/croptool/ and accept the certificate warning (since we issue a self-signed certificate)
To get jpegtran, we fetch the latest jpegsrc.xxx.tar.gz from the Independent JPEG Group. Note that the server returns "403 Forbidden" if you use the default curl user agent string.
curl -A "CropTool/0.1 (http://tools.wmflabs.org/croptool)" "http://www.ijg.org/files/jpegsrc.v9a.tar.gz" | tar -xz
cd jpeg-*
./configure
make
make testDownload deps and configure croptool:
composer install --optimize-autoloadercp config.dist.ini config.iniand insert OAuth info and the path to jpegtran.- Check that the server can write to
logsandpublic_html/files. vendor/bin/phpunitcrontab crontab.toolsto setup cronjobs.npm installgulp buildphp generate-key.php