CropTool is a tool for cropping image files at Wikimedia Commons and other Wikimedia sites using the MediaWiki API with OAuth.
Features:
- 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.
- Crop preview can be initialized from query string parameters:
?title=Example.jpg&left=10&top=10&width=150&height=100
or?title=Example.jpg&left=10&top=10&right=10&bottom=10
- Detects
{{Remove border}}
, Category:Images with borders,{{Watermark}}
and{{Trimming}}
, 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:FlickreviewR
subtemplates), since images should be reviewed before being altered. - Adds
{{Orphaned non-free revisions}}
when cropping non-free media on English Wikipedia.
- Request an OAuth 1.0 consumer at https://meta.wikimedia.org/wiki/Special:OAuthConsumerRegistration/propose with
- Callback URL: https://localhost:7878/
- Allow consumer to specify a callback in requests
- Grants: "Edit existing pages", "Create, edit, and move pages", "Upload new files" and "Upload, replace, and move files"
-
Copy
config.dist.ini
toconfig.ini
and add the consumer token and secret token toconfig.ini
docker compose run phpfpm composer install
npm install
- Build the frontend:
npx gulp build
- Generate secret for encrypted cookies:
docker compose run phpfpm php generate-key.php
- Start the development server on https://localhost:7878/
docker-compose up
Note that you should be able to login and preview cropping without waiting for the OAuth consumer to be accepted.
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 (https://croptool.toolforge.org)" "http://www.ijg.org/files/jpegsrc.v9a.tar.gz" | tar -xz
cd jpeg-*
./configure
make
make test
composer install --optimize-autoloader
cp config.dist.ini config.ini
and insert OAuth info and the path to jpegtran.- Check that the server can write to
logs
andpublic_html/files
. vendor/bin/phpunit
crontab crontab.tools
to setup cronjobs.php generate-key.php
On Toolforge, to use an up-to-date version of Node for installing dependencies, run:
$ webservice --backend=kubernetes node10 shell
This should start a new shell, from which you can run:
$ npm install npm
$ gulp build