Comment #4 on issue 2814 by
g.chr...@gmail.com: Automatically resize image
attachements
http://code.google.com/p/k9mail/issues/detail?id=2814
I have implemented this feature and committed the code to a fork of k-9 on
Github. Not knowing what to do next, I just post this comment and wait for
some reaction.
Here is how the feature was implemented: when attaching an image (or
multiple images), a pop-up will prompt the user for a resize option:
original size (no resizing), 1280x1024, 1024x768, 800x600, 640x400.
The images are resized to fit inside the chosen size; aspect ratio is of
course maintained. Rotation is also applied if necessary so that the result
will look the same as the original in terms of orientation.
Actual resizing happens when the message is queued for sending, i.e. just
after hitting the send button. As this happens in a background task, the
user won't see the resizing going on in the user interface. It will just
delay the actual sending of the message (which you may see in the
notification bar).
In this version, I have left a progress dialog when attaching the image(s).
But since at this stage, no real resizing is happening, it's always fast
and thus barely useful. I might remove it in the final version.
A note about memory usage: there are different techniques to resize an
image. I have used the most straightforward one and the one yielding the
best quality: the original image is fully brought into memory, resized and
written back to a temporary file. The potential problem with this is that
it uses quite a lot of memory. In some circumstances it may result in an
OutOfMemory. But since I have not yet been able to see it in any of my
tests, I have not bothered with implementing a second technique for low
memory situations. Might be necessary though. Waiting for feedback before
spending the time.
I have tested this on three different devices so far: Samsung Galaxy Nexus
running Android 4.1.1, Samsung Galaxy Note running Android 4.0.4 and my old
HTC Hero with only 192 MB of RAM running Android 2.2. It's working
perfectly on all three.