Commons talk:CropTool

From Wikimedia Commons, the free media repository
Jump to: navigation, search

Gadget[edit]

Any objection to make a gadget of this awesomeness? :-) Jean-Fred (talk) 09:40, 9 December 2013 (UTC)

Not from me :) – Danmichaelo (δ) 11:51, 9 December 2013 (UTC)
If I get the dependencies list then I'll set it up. /Lokal_Profil 19:36, 18 February 2014 (UTC)
✓ Done with the help of Steinsplitter. /Lokal_Profil 18:36, 12 March 2014 (UTC)
And text changed to point users to the gadget. Future .js updates (including an i18n mechanism) goes to the (edit-protected) Mediawiki:Gadget-CropTool.js page. /Lokal_Profil 11:37, 13 March 2014 (UTC)

Option to rename[edit]

The gadget worked great, but I'm creating a detail of a painting (File:Paolo Veronese - Adoration of the Magi - WGA24820.jpg) and certainly don't want to replace the original full view. I had been told the gadget would give me an option to rename the crop & create a new version, but it didn't. So I've reverted my cropped version & given the inflexibility of Commons, can't see how to split the crop version off from the file without exporting and reloading under a new name. Am I missing something? The gadget is rather dangerous in this state, as new detail crops may start replacing originals when they should not. But nice gadget! Johnbod (talk) 15:13, 18 December 2013 (UTC)

As for splitting: sysops can do it − see COM:SPLIT.
I agree with your general opinion. In fact, could it be possible to have the 'upload as new version' behaviour as default? Per COM:OVERWRITE, this is the most likely usecase.
Jean-Fred (talk) 15:55, 18 December 2013 (UTC)
upload new version as new file
It is possible to upload the new version as a new file (c.f. screenshot on the side). Also I think that the most used option is the first one (Overwrite original, which is already default). Having a look at Category:Images with borders reveals that most of the images that should be cropped rectangular only need some black (yellow, green or whatever color) border removed. This is considered a minor edit and always should overwrite the old version instead of creating a new file and leaving a useless piece of chunk behind which will eventually be nominated for deletion. --McZusatz (talk) 18:22, 18 December 2013 (UTC)
Thanks. Strange - I don't remember seeing that, and I was looking out for it; I'll experiment later. Category:Images with borders only gives one set of images the tool could be used on (I would say a fairly minor one), and it should not be assumed it is the main one. Vast numbers of images on Commons aren't really suitable for use in articles without cropping for compositional reasons, and others have details people could want to select, but should not be over-written. Is there a record of images cropped with the tool? COM:OVERWRITE specifically says only "minor" crops should overwrite. Nearly all the ones I am likely to do will be pretty major, and I'm sure there will be others like me. Before seeing this I re-uploaded my Veronese crop as File:20131218150544!Paolo Veronese - Adoration of the Magi - WGA24820cropped.jpg which only shows about 30% of the painting. Many very famous large paintings have their own categories with up to 30 cropped details - eg Category:Details of The Triumph of Death by Peter Bruegel the Elder with 26 files. Johnbod (talk) 15:40, 19 December 2013 (UTC)
Ok, it seems highly depended on the user. I may file a bug to request an option which allows the user to set a default behavior for himself. OK? --McZusatz (talk) 00:56, 20 December 2013 (UTC)
Johnbod, did you retry the tool? I'm aware of the risk, which is why I tried making the option to "upload as new file" easily visible, and also added a link to COM:OVERWRITE. It is also the reason why edit summaries include information about percentage cropped. An image replacement with an edit summary like "Cropped 26 % horizontally and 45 % vertically…"[1] should warn patrollers. A CropTool log is found here. Regarding which option to be the default, I'm not sure. McZusatz's idea about remembering the option per user seems like it might be a good idea. – Danmichaelo (δ) 14:16, 22 December 2013 (UTC)
Yes, I did, and of course found it. But I'm worried I hadn't the first time, even though I was looking for it. I think the type could be bolder. Let's see if bad overwriting becomes a common problem. Thanks for your responses all! It's certainly a great tool. Johnbod (talk) 03:00, 23 December 2013 (UTC)

Additional functions[edit]

Hello! Thanks for providing this useful tool. I would like to ask if some additional functionality could be developed and added, which would be useful for Wikivoyage community, but likely not only for us.

1) At WV we have a feature of Page banner, which uses photos cropped to 7:1 width to length ratio (usually 2100:300 px) (see Category:Wikivoyage_banners). For our work it would be very useful to be able to crop Commons pictures to a given ratio. 2) It would be great if the selection for cropping could be rotated, as well, in order to straighten non-horizontal horizons for example, while using this tool.

I wonder if such changes could be added. Thanks again! --Danapit (talk) 15:22, 19 December 2013 (UTC)

Danapit, these are both good ideas that I would like to add if I find time. Tracked as #17 and #18. – Danmichaelo (δ) 14:35, 22 December 2013 (UTC)
Danmichaelo, thanks for your feedback, it would be great to see the functions implemented ;) --Danapit (talk) 06:15, 24 December 2013 (UTC)
Great. I came here to suggest the same feature Dana but you beat me to it. --Saqib (talk) 13:58, 6 February 2014 (UTC)

Change in userscript[edit]

Note that I made a change in the userscript today to ensure filenames with special characters are passed correctly to the tool. If you have already added the code snippet to your Special:MyPage/common.js, you should update it to the new version. I paste it here too for convenience:

//CropTool code begins, see [[Commons:CropTool]] for details
(function(mw, $){
    if (mw.config.get( 'wgNamespaceNumber' ) !== 6) return;
    if (mw.config.get( 'wgAction' ) !== 'view') return;
 
    $( function () {
    	var title = mw.config.get( 'wgTitle' ).replace(/ /g, '_'),
            croplink = '//tools.wmflabs.org/croptool/?title=' + encodeURIComponent(title);
        mw.util.addPortletLink(
            "p-tb",
            croplink,
            "CropTool",
            "t-crop",
            "Crop this image"
        );
    } );
})(mediaWiki, jQuery);

Danmichaelo (δ) 22:53, 22 December 2013 (UTC)

What about importScript('CommonsMediawiki:croptool.js');? (The subpage needs to be created first, but for future updates no one will ever have to edit their common.js anymore.) --McZusatz (talk) 01:15, 23 December 2013 (UTC)
Seems like Commons:CropTool/croptool.js is not recognized as javascript. It's possible that js is only allowed in the MediaWiki and User namespaces, although I can't find a reference right now. Perhaps we should try to make it a gadget, do you know if there is a place to propose new gadgets? – Danmichaelo (δ) 11:28, 23 December 2013 (UTC)
In regards to gadgets, I think user:rillke can give you some useful links. --McZusatz (talk) 18:38, 23 December 2013 (UTC)
You are absolutely right: Only pages ending .js in MediaWiki and User namespace have the JavaScript content-model by default and for editing them special user rights apply: C.f. ContentHandler.php l.212 ff.
Separate scripts have the downside that for each of them, an extra request is made to the server; gadgets are better in this regard because they can be registered with ResourceLoader and thus be served together as just one with spaces and comments stripped (=minified). Nevertheless, this would the solution for adding this link, I am in favour for.
About gadgets: We already have plenty of them and how they are displayed and managed currently suggests that there shouldn't be too many of them, at least not gadgets visible in the preferences. A search through them is missing, tags, usage numbers/popularity, date created, compatibility and user rating as well and our current i18n system for both, the description and the gadget scripts are inefficient. -- Rillke(q?) 20:32, 23 December 2013 (UTC)

Remove watermark template[edit]

It would be helpful if CropTool also removed {{watermark}} if it is found on the description page, or at least if it had an option for doing that. darkweasel94 21:40, 24 March 2014 (UTC)

Yeah, planning to add that – Danmichaelo (δ) 20:49, 11 May 2014 (UTC)

Is it working?[edit]

I can't get it to work at all at the moment. It just takes me to the wmflabs page and it can't even get doing it from there to work. Johnbod (talk) 13:58, 6 May 2014 (UTC)

It works for me. Did you authenticate the app to do uploads in your name? --McZusatz (talk) 15:22, 6 May 2014 (UTC)
ages ago (as Johnbod), though recently it asked me to do it again, and it now isn't working for me. On this name I can't even get it to appear in the menu, despite ticking it in preferences. Wiki CRUK John (talk) 16:55, 6 May 2014 (UTC)
Hm, that's weird. If it doesn't even appear in the menu, it doesn't really sound like a problem specific to CropTool. Which browser did you use? Did you try others? – Danmichaelo (δ) 20:48, 11 May 2014 (UTC)

New problem with PNGs?[edit]

Hi, Today I'm finding it's impossible to edit PNG files using the crop tool. I get an error message that says:

File had unknown mime type image/png

An example is this image; as you can see in the edit history, I already did crop using CropTool a few days ago; but if I try to do so again today, I get the error message above. I also get it on similar PNG files in that category (but not a JPG I tested elsewhere). -Pete F (talk) 18:02, 4 July 2014 (UTC)

CropTool can only crop JPEGs. COM:CropTool says so in the first sentence. darkweasel94 18:19, 4 July 2014 (UTC)
Aah, I must have misremembered -- I cropped a few similar files by different processes last week. Thanks for setting me straight :) -Pete F (talk) 19:41, 4 July 2014 (UTC)

Edit conflicts[edit]

I'll just note here that CropTool doesn't currently handle edit conflicts well. Yesterday I had one (someone uploaded a new version while I was selecting my crop region) and, when previewing, simply got no image, and then "Upload failed" when trying to upload. I don't know if it's possible at all to give a better error message in that case (I only realized what was going on when visiting the file page again), but if it is, it should be done. darkweasel94 08:55, 17 July 2014 (UTC)

@Darkweasel94: I'll look into it. It should be possible to give a better error message. – Danmichaelo (δ) 09:13, 23 August 2014 (UTC)

Review templates[edit]

Please ensure that license review templates are not copied into the cropped images as they have never been reviewed. This are templates like License review, Flickrreview or several upload bot review templates. --Denniss (talk) 21:39, 15 August 2014 (UTC)

Another tweak would be to add a carriage return/line feed after placing the extracted from template so it's not mangled with cats. --Denniss (talk) 22:00, 15 August 2014 (UTC)

Using it with local images at the Wikipedias[edit]

To use CropTool with local images at any other Wikimedia project than Commons, add the following code snippet for your common.js file. The wgRevisionId check ensures it only shows up in the Tools menu for local files:

//CropTool code begins, see https://commons.wikimedia.org/wiki/Commons:CropTool
(function(mw, $){
    if (mw.config.get( 'wgNamespaceNumber' ) !== 6) return;
    if (mw.config.get( 'wgAction' ) !== 'view') return;
    if (!mw.config.get( 'wgRevisionId' )) return;

    $( function () {
        var title = wgServer + wgArticlePath.replace( '$1', wgPageName ),
            croplink = '//tools.wmflabs.org/croptool/?title=' + encodeURIComponent( title );
        mw.util.addPortletLink(
            "p-tb",
            croplink,
            "CropTool",
            "t-crop",
            "Crop this image"
        );
    });
})( mediaWiki, jQuery );

Danmichaelo (δ) 10:50, 23 August 2014 (UTC)

Where is the commons.js file? I didn't see it at my Commons Pref page. TIA, Pete Tillman (talk) 20:35, 26 August 2014 (UTC)
You may find it over here: [[special:myPage/common.js]]. --McZusatz (talk) 22:36, 28 August 2014 (UTC)

Croptool is down[edit]

https://tools.wmflabs.org/croptool/ is returning error messages for the last 2 days. Help? Cropbot is also down. --Pete Tillman (talk) 15:03, 10 October 2014 (UTC)

File:Wien 132 (3186743779).jpg[edit]

I'm having trouble cropping File:Wien 132 (3186743779).jpg. For some reason the image appears rotated by 90 degrees when loaded in CropTool. If I then select the crop region I want on that rotated image, it crops something totally different and adds a gray area below the cropped image, with a suggested edit summary "Cropped -31 % horizontally and 26 % vertically using CropTool with lossless mode.". Doing a 0° rotation with Rotatebot didn't work. darkweasel94 18:07, 30 November 2014 (UTC)

@Darkweasel94: Sorry it took so long to fix this. This turned out to be due to a bug in the imagemagick library used by the tool. See issue #45 for more info. – Danmichaelo (δ) 17:35, 12 April 2015 (UTC)

scale[edit]

is it possible to scale a photo, so that you can choose to keep the ratio the same, say 3:4 -- Cherubino (talk) 00:45, 9 May 2015 (UTC)