Jump to content

Commons talk:CropTool

Add topic
From Wikimedia Commons, the free media repository
Latest comment: 8 days ago by Bawolff in topic Broken templates in cropped images
This is the talk page for discussing improvements to Commons:CropTool.
Archives: 1, 2, 3, 4, 5

Lossless mode no longer working?

[edit]

@Danmichaelo, is lossless mode still working. I used to get messages that the crop size had been adjusted because I wasn't starting on a multiple of 8 or 16, but this has gone away. Similarly, there's a bug report on github (#170) reporting that files that should be uncroppable in lossless mode are now working, but produce the same files as if they were in precise mode. Is the tool silently falling back to precise when lossless doesn't work (which would be undesirable), or is something else going on here? Perhaps a bug introduced in the September 2020 refactoring? Ahecht (TALK
PAGE
) 14:59, 15 June 2022 (UTC)Reply

Looking into the code more, it seems like the September 2020 refactor fundamentally broke things. The various types of crop were broken out into subclasses (for example, lossless Jpeg cropping was broken out into JpegFile and Gif cropping to GifFile), but as far as I can tell the only subclasses that are actually being called out by the program in FileRepository.php are TiffFile, DjvuFile, PdfFile, and SvgFile, all of which return errors instead of actually working. All other file types are being handled by the generic imagemagick call in File.php.
This is why lossless crops are no longer lossless, Gif files say they are being cropped with precise or lossless mode instead of "gif mode", and TIFFs, PDFs, and DJVUs no longer work.
If these issues aren't easy to resolve, perhaps to the tool should be rolled back to 1.4 (before the refactoring). Ahecht (TALK
PAGE
) 14:18, 17 June 2022 (UTC)Reply
just confirming this issue persists 2023-01.--RZuo (talk) 11:53, 15 January 2023 (UTC)Reply
Since about 9-2021 Danmichaelo's only contributions have been edits to wikidata and some edits in norwegian and finnish wikipedia about some meta-topics (bot problems, ...). I seem to remember that them was unhappy with a decission at english wikipedia. That leaves two ways of action: Appease them to return to wikipedia, or find a new maintainer for croptool. Just waiting woll not help. C.Suthorn (talk) 15:34, 15 January 2023 (UTC)Reply
sigh :/
there were a few commits https://github.com/danmichaelo/croptool/commits/master .
i know someone might have to take over, but i reposted this thread because this is a major issue which should not be archived until it's resolved. RZuo (talk) 18:25, 15 January 2023 (UTC)Reply
Bumping thread Ahecht (TALK
PAGE
) 19:19, 16 February 2024 (UTC)
Reply
i think, with https://github.com/danmichaelo/croptool/pull/182 merged 2 days ago, lossless mode has now returned. i just tried previewing random crops in lossless mode and they were now being augmented to the left and the top again.
thx a lot @Danmichaelo, @Christoph Jauera (WMDE) and @TMg! RZuo (talk) 14:35, 20 February 2024 (UTC)Reply
User:Danmichaelo Crop from .svg files still not working. Was this supposed to fix it? Doc James (talk · contribs · email) 15:34, 23 April 2024 (UTC)Reply
Trying to crop File:Johnson and Johnson Marketing Ad Kilmer Opera House Pharmacy 1888.jpg went [Error] undefined when using lossless mode. Had to use precise mode. - Alexis Jazz ping plz 11:43, 11 January 2025 (UTC)Reply

Similar to Croptool tool to change exposition

[edit]

Is there any Similar to Croptool tool to change exposition? Alex Blokha (talk) 23:06, 18 February 2025 (UTC)Reply

@Alex Blokha: not sure what you mean by "exposition". Maybe lightness ("exposure", though technically "exposure" happens entirely at the time you snap the shutter, so exposure as such cannot be changed)? Or do you mean something else? - Jmabel ! talk 00:04, 19 February 2025 (UTC)Reply
Yes, I mean lightness. I need to make image more light or more dark. Alex Blokha (talk) 01:09, 19 February 2025 (UTC), and a good tool for that takes a good bit of work; it's tricky to do client-side in a browser window. (Theoretically you could do it with JavaScript and HTML Canvas.) I'd suggest that if you need to do that, download a full-res copy to your own PC and do it there. The Colors > Curves tool in GIMP does this well and flexibly (e.g. lets you keep highlight as they are while lightening other ranges). - Jmabel ! talk 05:46, 19 February 2025 (UTC)Reply
User:Alex Blokha Yes we built this [1] Doc James (talk · contribs · email) 16:43, 27 March 2025 (UTC)Reply
@Doc James: I don't see anything there that looks like it has the requested capability. It looks to me like strictly a tool for adding text annotations to an image, not for making it brighter or darker. Am I missing something? - Jmabel ! talk 01:47, 29 March 2025 (UTC)Reply
Under "filters" bottom right and then you can move the brightness toggle. You have to select the square box to the left first. Doc James (talk · contribs · email) 19:35, 29 March 2025 (UTC)Reply
I see. That lets you change brightness over the whole image, and might deal well with straight-out overexposure or underexposure. However, in my experience, that's not terribly useful. You really want at least to be able to adjust shadows, midrange, and highlights independently, and probably the different color channels, and ideally have something like the GIMP "Curves" tool. So, yes, there are some cases that would cover, but I suspect it is a definite minority. If you want a good example of where it won't help, try looking at File:Pfeiffer Big Sur State Park - tree round 01.jpg. - Jmabel ! talk 22:29, 29 March 2025 (UTC)Reply
How can I put it to sidebar like Croptool? Alex Blokha (talk) 20:24, 26 May 2025 (UTC)Reply
Ок, I've written script for sidebar by myself, using LLM
// <nowiki>
mw.loader.using(['mediawiki.util'], function () {
    /**
     * Check if we are in the "File" namespace (Namespace ID 6).
     * If not, the script skips execution.
     */
    if (mw.config.get('wgNamespaceNumber') === 6) {
       
        // Get the full page name (e.g., File:Kkpk_truck_in_Dnipro.png)
        var pageName = mw.config.get('wgPageName');
       
        // Construct the URL for the ISA Tool
        // encodeURIComponent ensures special characters are handled correctly
        var targetUrl = 'https://image-annotation-tool.wmcloud.org/?file=' + encodeURIComponent(pageName);
        // Add the link to the sidebar toolbox (Portlet Link)
        mw.util.addPortletLink(
            'p-tb',             // ID of the "Tools" portlet (Toolbox)
            targetUrl,          // The target URL
            'ISA Tool',         // Link text to display
            't-isa-tool',       // Unique ID for the HTML element
            'Open this file in the Image Annotation Tool', // Tooltip text (on hover)
            null,               // Access key (can be null)
            null                // Next node (null = append to the end of the list)
        );
    }
});
// </nowiki> Alex Blokha (talk) 23:38, 8 December 2025 (UTC)Reply

image annotations broken upon cropping

[edit]

If images have been annotated before cropping (like e.g. mountain peaks), my impression is that these annotations will be broken upon cropping, as the image width and / or height will not fit the parameters in the Template:ImageNote expressions any more (broken usually means: they will not be displayed at all). Recent example: File:Palù Unterkrumpwasser - m 2228 s.l.m. (BZ) - panoramio.jpg, cropped by User:Joalbertine vertically (the width remained the same, the height was reduced by 90px). As a "quick and dirty" workaround, it is possible to adjust the image height parameters in the file manually (that is what I just did in the file mentioned), which works fine if the (mountain) image is cropped only by height and the annotation boxes are close to the upper end of the image (where the zero coordinate is located). If also horizontal cropping only at the right hand side is done, everything is still fine. If a vertical strip was cropped at the left hand side, though, the position coordinates would have to be corrected manually somehow.

I see that such corrections of the latter case can probably hardly be done automatically. As a workaround, however, I'd suggest that 1) at least the image width / height parameters in the ImageNote expressions could be adjusted automatically (then the annotation boxes would at least be displayed, even though not precisely at the correct position. If appropriate, I would suggest to 2) add a warning like "Attention: this image was annotated and cropped later. The positions of the annotation boxes may not be accurate any more." And / or 3) during the process of using the Croptool, a warning could show up that says something like: "Attention: You are about to crop an annotated image. If you proceed cropping, the annotations may be broken or inaccurate afterwards. Please check the annotations manually afterwards or ask the original user who did the annotations for help." What do you think?

I'm doing annotations quite often (predominantly mountain photographs), and I would regret if they are broken after any cropping. --Kuhni74 (talk) 10:33, 14 July 2025 (UTC)Reply

Hi - nice tool! But definitely has the annotation problem described by Kuhni74!
As the crop tool does no or no complicate rotations (maybe only changing the exif orientation entity?), recalculation of the annotation coordinates should be a nice challenge for some kind of programming workshop, coding summer or something like that. Shouldn't really be that difficult.
Until that feature is added, for images with annotations there should definitely be:
  • a warning before saving
  • the original should not be overwritten
  • plus there should always be a note in the edit summary
Nice example for what the problem is [2] -- Schusch (talk) 13:42, 6 November 2025 (UTC)Reply
the original should not be overwritten: I occasionally use the CropTool to crop annotated images. I consistently clean up the ImageNotes afterward. I would not want to lose the ability to use the crop tool for this. A warning is fine, but it needs to be possible to override it. Probably it should add a maintenance category, which a user could remove after cleaning it all up. (Of course, having the CropTool actually fix the annotations would be better.) - Jmabel ! talk 18:46, 6 November 2025 (UTC)Reply
As the crop tool does no or no complicate[d] rotations: not true, you can rotate by any multiple of 0.01 degree. - Jmabel ! talk 18:46, 6 November 2025 (UTC)Reply
  • crop annotated images: cropping as i realize it is mostly without rotating - so recalculation of coordinates for annotations should be easy (algorithm should work something like this: recalculate box borders, check if box is completely in new frame, if yes, insert, if not, check if remaining rest of box is at least x pixel (with x = 20? or at least 2 % of height or width?) high or wide - if big enough, add remaining rest of box to image, otherwise dismiss the box completely); so if the annotation are lost at least there would be the note in the edit summary ... (and we have a version history :-)
  • rotating by any multiple of 0.01 degree: didn't realize the rotating possibility in my very short check (never used the tool up to now), sorry for that ... but even then it should not be very difficult to integrate a calclulation for new coordinates
as I said: for me it sounds like a nice task for programming course or competition - if there are such events in the wiki[p|m]edia world ... -- Schusch (talk) 19:29, 6 November 2025 (UTC)Reply

Broken templates in cropped images

[edit]

Hi, is anyone working on this issue? This is a consistent problem in all cropped files (for example, File:Andrees Handatlas - Haiti und Puerto Rico.jpg) and I don't think it is my responsability as the one who does the cropping, to fix the template in the resulting image, especially since the github people purposefully programmed it that way to discourage usage of the {{book}}-template. --Enyavar (talk) 10:28, 24 July 2025 (UTC)Reply

@Doc James: can this issue also be looked into please? I work with PDF and DJVU files a lot of times and the resulting image post crop has broken templates. I've had to manually fix those.
I would suggest - Crops from files using the Book template should use the basic Information template and an optional field to enter the new description (especially when uploading a new image) would be great. PDF and DJVU templates on the result file should also be removed. Ciridae (talk) 13:13, 6 January 2026 (UTC)Reply
So basically if the starting image uses the book template than the final image should use the book template? User:Bawolff can we add this functionality per the bug report? Doc James (talk · contribs · email) 14:24, 6 January 2026 (UTC)Reply
@Doc James: No, even if the starting file, PDF or DJVU, uses the Book template, the final cropped image should use the Information template by default because the final image will never be a book but an image file. Also, a PDF or DJVU template is added to books uploaded from Internet Archive (and others) which should also be removed. Ciridae (talk) 13:57, 8 January 2026 (UTC)Reply
@Enyavar The tool should no longer break templates when removing {{Book}}. However I gather that's not fully what is wanted here. Its not fully clear to me how the tool should act when a book template is present, since for example, File:Andrees Handatlas - Haiti und Puerto Rico.jpg does not have all the fields of the information template. Currently the tool can only delete templates but not interpret them, so having it convert {{Book}} to {{Information}} might be quite a bit of effort. Bawolff (talk) 05:16, 6 February 2026 (UTC)Reply

Glitch

[edit]

When I click on an image (say File:Tolrestat synthesis.svg) and then "more details" then hit the "Crop Tool", I am sent to What to crop? Enter the URL or filename for an image you would like to crop." Obviously I want to crop the image that I selected. Anyway, I enter the url of the image. Doesnt work.--Smokefoot (talk) 14:20, 7 August 2025 (UTC)Reply

@Smokefoot: What page were you on when you clicked on the file and then "more details"?   — 🇺🇦Jeff G. please ping or talk to me🇺🇦 14:55, 7 August 2025 (UTC)Reply
https://en.wikipedia.org/wiki/Thioamide#/media/File:Tolrestat_synthesis.svg
then click "more details"
https://commons.wikimedia.org/wiki/File:Tolrestat_synthesis.svg
then click "crop tool" (this sequence worked many times in the past)
https://croptool.toolforge.org/?title=Tolrestat_synthesis.svg (asking me to identify the image to be cropped, but the image is never accepted).

--Smokefoot (talk) 15:04, 7 August 2025 (UTC)Reply

@Smokefoot: Thanks. It failed the same way for me (after I used OAuth to authenticate). Pinging @Danmichaelo as maintainer.   — 🇺🇦Jeff G. please ping or talk to me🇺🇦 15:10, 7 August 2025 (UTC)Reply
Same issue for me. Zanahary (talk) 18:36, 20 August 2025 (UTC)Reply

"Upload failed! undefined" is back again

[edit]

Crop tool failed repeatedly with the above error message when I tried to crop a Commons .PNG today. There was nothing unusual about the file or the cropping steps, as far as I can see. It just isn't working today. -- WikiPedant (talk) 18:35, 2 September 2025 (UTC)Reply

OK, it's working again now. -- WikiPedant (talk) 01:59, 3 September 2025 (UTC)Reply
It's back again. Kaasterly (talk) 03:34, 5 October 2025 (UTC)Reply
@Kaasterly: meaning the problem is back again, or the correct behavior is back again?? - Jmabel ! talk 15:09, 5 October 2025 (UTC)Reply
It seems the latter. I thought there was a problem with CropTool, but it seems to have been just because I was trying to overwrite a file which I didn't have overwrite permissions for. Kaasterly (talk) 15:51, 6 October 2025 (UTC)Reply

A problem

[edit]

When I click on an image and then hit the "Crop Tool", I am sent to What to crop? Enter the URL or filename for an image you would like to crop." I enter the url of the image and Doesnt work. For example: https://croptool.toolforge.org/?site=commons.wikimedia.org&title=Copiapoa+longispina+6.jpg RamsesVII (talk) 13:54, 2 October 2025 (UTC)Reply

@RamsesVII: what I see at that URL looks fine to me, so what do you mean by "doesn't work"? - Jmabel ! talk 02:42, 3 October 2025 (UTC)Reply
Hello. It's finally resolved. Thank you very much for replying. Best regards. RamsesVII (talk) 07:21, 3 October 2025 (UTC)Reply
Hi. Anyone else having problems with CropTool? The message I've been getting all day is: 504 The CropTool backend is currently having problems. --Rosiestep (talk) 21:04, 5 October 2025 (UTC)Reply
I'm having the same problem (have tried both Firefox and Chrome on Mac). —Mx. Granger (talk  · contribs) 21:55, 5 October 2025 (UTC)Reply
This now seems to be fixed for me. @Rosiestep: How about you? —Mx. Granger (talk  · contribs) 12:23, 6 October 2025 (UTC)Reply
Fixed for me, too. Thanks. --Rosiestep (talk) 13:38, 6 October 2025 (UTC)Reply
I am still having this problem too Bloopityboop (talk) 23:23, 6 October 2025 (UTC)Reply
I also encountered a 504 error and it has not been fixed yet. Thyj (talk) 09:20, 7 October 2025 (UTC)Reply

CropTool2

[edit]

We at Wiki Project Med have been funding improvements to the CropTool and have forked it to create [3]. For those who wish to use this new version (which handles SVGs for example) turn off the current croptool in your preferences and add the following to your personal .js as seen here User:Doc_James/vector-2022.js Doc James (talk · contribs · email) 16:19, 9 October 2025 (UTC)Reply

@Doc James: is there any reason this should not simply supersede the current CropTool? - Jmabel ! talk 01:18, 10 October 2025 (UTC)Reply
We would be fine with that. We forked it as the current maintainer of CropTool is not really responsive. We plan to continue funding the maintenance of this version.
We are currently working on improving its handling of large files. But are open to further suggestions. Doc James (talk · contribs · email) 01:48, 10 October 2025 (UTC)Reply
@Doc James: If the current maintainer is not responsive, you could propose switching over at COM:VPP, with a ping to the unresponsive maintainer and a link from COM:VPT. - Jmabel ! talk 13:42, 10 October 2025 (UTC)Reply
For what it's worth, you can't really usurp/supersede the original tool per the right to fork policy. However, for all intents and purposes, folks should be able to use CropTool2 over the original CropTool. Particularly, a interface-administrator should update MediaWiki:Gadget-CropTool.js. Sohom (talk) 16:21, 10 October 2025 (UTC)Reply
Or the option in preferences could change over to offer CropTool2. - Jmabel ! talk 21:05, 10 October 2025 (UTC)Reply
I am happy with whichever option you folks think is best. Doc James (talk · contribs · email) 23:18, 14 October 2025 (UTC)Reply

We just added another improvement. CropTool2 now handles images 10 fold larger than CropTool. For example it will work with this.[4] Doc James (talk · contribs · email) 23:20, 14 October 2025 (UTC)Reply

@Doc James, could the tool provide an option to restrict the crop to the image area when using arbitrary rotation in precise mode? 𝟙𝟤𝟯𝟺𝐪𝑤𝒆𝓇𝟷𝟮𝟥𝟜𝓺𝔴𝕖𝖗𝟰 (𝗍𝗮𝘭𝙠) 00:24, 17 October 2025 (UTC)Reply
Sure could add that to the development list such that when people enter a rotation it gives you the option to keep within the image area. Doc James (talk · contribs · email) 00:37, 17 October 2025 (UTC)Reply
@Doc James: "open" => "option", or something else? - Jmabel ! talk 12:12, 17 October 2025 (UTC)Reply
Yes thanks, corrected. Doc James (talk · contribs · email) 15:46, 17 October 2025 (UTC)Reply

CropTool2 is now the version offered as a gadget. - Jmabel ! talk 23:12, 14 December 2025 (UTC)Reply

Question

[edit]

Hello. Any ideas on why "Upload failed! undefined" is happening when I try to overwrite a file? It doesn't appear when I try to upload it. Nedia020415 (talk) 21:48, 10 October 2025 (UTC)Reply

@Nedia020415: Any chance the file is protected, or that you lack the relevant rights to overwrite it? (It might help if you say what file.) - Jmabel ! talk 02:16, 11 October 2025 (UTC)Reply
Oh, ok. Thank you! Nedia020415 (talk) 02:24, 11 October 2025 (UTC)Reply
I'm having the same issue on File:Christine Nielsen Museum Director and Curator.jpg
This is my first major edit on Commons other than uploading so I don't really know what I'm doing :) SnowyRiver28 (talk) 08:25, 22 October 2025 (UTC)Reply
@SnowyRiver28: presumably you do not have the autopatrol right that would let you overwrite someone else's upload. What is the reason you want to overwrite this? It would seem much more likely that you should save off a different version without removing the one we have. - Jmabel ! talk 13:40, 22 October 2025 (UTC)Reply
Sorry, I read COM:CROP briefly and assumed this would fit the ‘minor changes and implements section’, specifically a minor crop, and I’ve had my own uploads cropped and overwritten so I assumed this was standard practice. SnowyRiver28 (talk) 18:49, 22 October 2025 (UTC)Reply
@SnowyRiver28: I’ve had my own uploads cropped and overwritten: what file(s) are you referring to? I cannot readily find a case where that occurred. - Jmabel ! talk 03:00, 23 October 2025 (UTC)Reply
They were made with previous accounts some years ago I believe, but that’s beside the point. Would this consist of a ‘major crop’ in the eyes of COM:CROP and therefore warrant making a new file? SnowyRiver28 (talk) 03:07, 23 October 2025 (UTC)Reply
@SnowyRiver28: it is hard to imagine any desirable minor crop that would be an appropriate overwrite of that file. It has no unneeded borders; the horizon line seems unproblematic; it is reasonably well composed. It seems to me that if you want a version that is differently cropped, it should not be an overwrite. What exactly do you have in mind? - Jmabel ! talk 18:06, 24 October 2025 (UTC)Reply
Yeah that makes sense. I think my confusion here stems from me misunderstanding what consists of a major and minor crop per COM:CROP. I'll do some more reading and know for next time, thanks for your comments :) SnowyRiver28 (talk) 23:46, 24 October 2025 (UTC)Reply

Cursor hardly visible

[edit]

The grey cursor is hardly visible out of the cropped area, i cannot attach a screenshot, because the screenshots don't show the cursor as I see it. The problem is, that inside the crop box, I see four-way arrow. Outside the box, the grey crosshair is shown, but grey on grey background isn't visible. Probably only Win11-related... I don't have an account at GitHub and I don't want it, so I report it here. — Draceane talkcontrib. 09:29, 21 November 2025 (UTC)Reply

Yah able to duplicate that. We will try to fix it in the CropTool2 Doc James (talk · contribs · email) 20:03, 10 December 2025 (UTC)Reply
User:Bawolff let me know if you see the problem and if we can improve contrast? Doc James (talk · contribs · email) 14:25, 6 January 2026 (UTC)Reply
✓ Done We replaced the crosshairs cursor with a higher contrast image. So it should now use the same crosshair cursor on all platforms. Bawolff (talk) 05:11, 6 February 2026 (UTC)Reply

Crop tool has disappeared

[edit]

This happened several days ago. I found it somewhere and had it in a tab, but now I've lost it again and can't remember where I found it before. Spent frustrating time looking for it. Krok6kola (talk) 05:40, 4 December 2025 (UTC)Reply

@Krok6kola: do you have "⌗ CropTool" in your "Tools" list on image pages? If you don't, then go to Special:Preferences, click "CropTool", and turn it on. (This assumes that you use the default CropTool, not the improved version from WikiMed that is currently proposed as a replacement.) - Jmabel ! talk 20:02, 4 December 2025 (UTC)Reply
@Jmabel: It is checked under special preferences. Just that I cannot access it. It does not appear anywhere. Krok6kola (talk) 08:31, 5 December 2025 (UTC)Reply
Bizarre.
Anyway, there is https://croptool2.toolforge.org/, which is an improved version, and I recommend you just use that. You can either navigate to that page or, assuming you are using the Vector2022 skin, you can copy User:Doc James/vector-2022.js to User:Krok6kola and this improved version of CropTool should show up in you tool set. - Jmabel ! talk 18:42, 5 December 2025 (UTC)Reply
@Krok6kola "had it in a tab"
you can have it again simply by reading and following Commons:CropTool#Setup. RoyZuo (talk) 19:04, 5 December 2025 (UTC)Reply
I don't quite understand this. I have gone to that link but it is unclear what I do next. Krok6kola (talk) 19:39, 5 December 2025 (UTC)Reply
Just above the tutorial section, there's the setup section. Should be as easy as clicking "Activate CropTool!" in that section. --Engineerchange (talk) 19:41, 5 December 2025 (UTC)Reply

Problem with DJVU

[edit]

Hello, I can't manage to use croptool for DJVU files on commons (with this example). It gives me the following message : (Command not found: "/usr/local/bin/magick '/workspace/public_html/files/303803465aae314a3c2982800f9418cc1da1dc9c.djvu.page1.jpg.tiff' '/workspace/public_html/files/303803465aae314a3c2982800f9418cc1da1dc9c.djvu.page1.jpg' 2>&1"). Someone can help me ? I already use it for this type of use, but now it doesn't work. Olivier LPB (talk) 12:45, 22 December 2025 (UTC)Reply

I think that i found my problem, the link with the widget go to "croptool2".toolforge... and not "croptool", i change the ref in the navigation barr and now it's work. Olivier LPB (talk) 16:09, 22 December 2025 (UTC)Reply
 Comment, I also got this error in CropTool2 for DjVu files. However, as mentioned above, the error only exist for CropTool2, but not the original CropTool. Thanks. Tvpuppy (talk) 18:53, 22 December 2025 (UTC)Reply
Thanks for this. We will work on fixing this issue with croptool2. Doc James (talk · contribs · email) 19:41, 22 December 2025 (UTC)Reply
✓ Done this should be fixed now Bawolff (talk) 21:49, 4 January 2026 (UTC)Reply