Auto Crop removes part of the image

Bug #1191390 reported by Nichole Ober on 2013-06-15
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Pinta
Medium
Unassigned

Bug Description

Using the Auto Crop tool under image removes too much of the image. This is very noticeable when using the tool when there's nothing to crop. Instead of leaving the canvas alone, the left, bottom, and right pixels will get cut off by 1 pixel. If the tool is used repeatedly, the image will eventually shrink to nothing. The program will also completely crash if the canvas gets re sized too small, showing a box with no text or buttons, then terminating completely.

The best way to test this is to open any image and hold the key combo for auto crop (ctrl + alt + x).

The code for autocrop can be found in Pinta.Core/Actions/ImageActions.cs on line 191. It seems like an easy fix.

Changed in pinta:
importance: Undecided → Medium
status: New → Confirmed
grofaty (grofaty) wrote :

I managed to reproduce the crash on master on Windows XP:
1. New image.
2. Pencil from Tools and on canvas just click to create one dot.
3. Image | Auto crop and crash appears with the following error:
=============
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DivideByZeroException: Attempted to divide by zero.
   at Pinta.Core.DocumentWorkspace.set_Scale(Double value) in c:\Zaloga\Pinta-master\Pinta.Core\Classes\DocumentWorkspace.cs:line 100
   at Pinta.Core.ImageActions.CropImageToRectangle(Document doc, Rectangle rect) in c:\Zaloga\Pinta-master\Pinta.Core\Actions\ImageActions.cs:line 286
   at Pinta.Core.ImageActions.HandlePintaCoreActionsImageAutoCropActivated(Object sender, EventArgs e) in c:\Zaloga\Pinta-master\Pinta.Core\Actions\ImageActions.cs:line 268
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
  at GLib.Signal.ClosureInvokedCB(Object o, ClosureInvokedArgs args)
   at GLib.SignalClosure.Invoke(ClosureInvokedArgs args)
   at GLib.SignalClosure.MarshalCallback(IntPtr raw_closure, IntPtr return_val, UInt32 n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
=============

P.S. I am removing easy-to-fix tag. This code requires some knowledge how auto crop works and easy-to-fix is tag for total beginners.

tags: added: crop-tool
removed: crop easy-to-fix tools
tags: added: auto-crop-tool
removed: crop-tool
Nichole Ober (nicholeober) wrote :

Fair enough. I put easy-to-fix because no knowledge specific to pinta seems to be needed (just some miscalculated for loops that need fixing).

Honestly, I'll give this a go. If I can't fix it in a week from now, I'll un-assign myself. I assume I just branch and push like it says here? `https://code.launchpad.net/pinta`

Changed in pinta:
assignee: nobody → Nichole Ober (nicholeober)
Cameron White (cameronwhite91) wrote :

All of the development for Pinta is done on Github (see http://pinta-project.com/contribute.ashx for instructions). Launchpad automatically imports the code from Github, but we only use that for setting up the daily builds PPA.

Changed in pinta:
assignee: Nichole Ober (nicholeober) → nobody
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers