Giter Site home page Giter Site logo

matthewlw / croptool Goto Github PK

View Code? Open in Web Editor NEW

This project forked from danmichaelo/croptool

0.0 0.0 0.0 1.39 MB

Tool for cropping images at Wikimedia Commons and other Wikimedia wikis

License: Other

JavaScript 15.49% PHP 67.19% CSS 1.58% Shell 0.12% Python 0.69% HTML 14.81% Dockerfile 0.11%

croptool's Introduction

CropTool

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.
  • 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,
  • Stops users from cropping images waiting for license review (having {{Flickrreview}} without any parameters, or some of the User:FlickreviewR subtemplates), since images should be reviewed before being altered.
  • Adds {{Orphaned non-free revisions}} when cropping non-free media on English Wikipedia.

Setting up a development environment

  1. 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"
  1. Copy config.dist.ini to config.ini and add the consumer token and secret token to config.ini

  2. Install dependencies using Composer and NPM:

composer install
npm install
  1. Build the frontend:
npx gulp build
  1. Generate secret for encrypted cookies:
php generate-key.php
  1. 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.

Deployment notes

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

Download deps and configure croptool:

  1. composer install --optimize-autoloader
  2. cp config.dist.ini config.ini and insert OAuth info and the path to jpegtran.
  3. Check that the server can write to logs and public_html/files.
  4. vendor/bin/phpunit
  5. crontab crontab.tools to setup cronjobs.
  6. php generate-key.php

Frontend build:

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

croptool's People

Contributors

anticompositenumber avatar danmichaelo avatar mwootten avatar scrutinizer-auto-fixer avatar sikanderiqbal avatar simon04 avatar steinsplitter avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.