Ticket Hash: | 7044332162761fca554b3876d8d7f06a61d77858 | |||
Title: | resizing images with high quality | |||
Status: | Closed | Type: | Code_Defect | |
Severity: | Minor | Priority: | Immediate | |
Subsystem: | Resolution: | Open | ||
Last Modified: | 2019-08-31 11:24:24 | |||
Version Found In: | ||||
User Comments: | ||||
john added on 2019-07-01 18:34:07:
You showed me a source file that had an undocumented image resize function, which I believe was part of an image rotation feature. However, now my memory is unclear as to what you were showing me, so I'm following up. I've grepped the Androwish source, and in BLT found Blt_ResamplePhoto -> Blt_ResizePhoto -> ResampleOp which leads to ->BLT's "resample" command. I found a mention that it was a "undocumented subcommand" so is this what you were referring to? An example of its use is given on page 53: https://www-cdf.lbl.gov/~igv/Docs/blt_slides.pdf -john Managing graphs with tabsets (cont’d) winop resample resample operation does arbitrary resizing. ● 1-D image filters: box, triangle triangle, sinc, etc. ● Eventually function will move to new image type. proc Thumbnail { graph w h } { set image [image create photo] $graph snap $image set thumb [image create photo -width $w -height $h] winop resample $image $thumb box box image delete $image return $thumb } set nTabs [.t size] for { set tab 0 } { $tab < $nTabs } { incr tab } { set graph [.t tab cget $tab -window] button .f.b$tab -image [Thumbnail $graph 200 200] \ -command [list .t invoke $tab ] table .f .f.b$tab $row,$col … chw added on 2019-07-02 02:45:36: In AndroWish/undroidwish/vanillawish the patch from https://wiki.tcl-lang.org/page/Enhanced+photo+image+copy+command is integrated. This should allow you to do: image create photo ORIG -file picture.png ;# original image create photo NEW ;# for copy NEW copy ORIG -scale 0.7 ... ;# scaled version Another option is the tclepeg package (package require tclepeg) which provides downscaling of jpeg data, see doc in https://wiki.tcl-lang.org/page/epeg john added on 2019-07-02 19:24:54: Ah yes, I found that too, but it doesn't let you specify a destination resolution. It uses a scaling factor. That made me a bit nervous that the new image wouldn't be exactly the X/Y dimensions I wanted. I will test it, and the BLT function, and report back. As the the JPEG resize, I found that too, but I use PNG in order to avoid lossy artifacts, which are very visible in things like drop shadows (that I use quite a bit). chw added on 2019-07-04 17:44:33: I see and therefore added the -scaleto option in check-in [01e4d678d7]. The idea is that you now can specify either the destination width and height or the destination width only, in which case the height is computed from the scaling. Please give it a shot. john added on 2019-07-08 11:58:59: I'm temporarily w/o a "build from source" computer, as I've reformatted my macbook froms cratch solve so lots of OS-upgrade problems, so I can't test your -scaleto addition at the moment. However, I line-by-line read through your patch, and your implementation looks clean, and I didn't see any issues. Thanks for doing the maths to convert a resolution to a scaling factor. Hopefully your improvement will be accepted up-stream. chw added on 2019-07-08 20:13:20: For testing on droids you can use this download http://www.ch-werner.de/AndroWish/AndroWish-debug.apk which is a current built from 2019-07-08. john added on 2019-08-15 15:39:51: I now confirm that this feature works as described, on Android. When you have time, I would appreciate a new build of undroidwish for other OSes, that has this feature. That way I can enable -scale on undroidwish as well. With different screen resolutions on Desktop computers, this new feature will be very useful on undroid. john added on 2019-08-15 17:55:25: hmm... no, I confused myself, and I actually cannot make this work. Here is a simple test program that works on undroidwish but NOT on the new Androidwish I just installed from you: set src [image create photo -file in.png] set new [image create photo] $new copy $src -scale 0.5 $new write "new.png" exit On the new Androidwish you sent me, I am getting the error that "-scale" is an unknown parameter, but it is listed in the accepted parameters. I've taken a photo of that error: http://magnatune.com/p/scaleto.jpg Also note that changing from -scale to -scaleto causes Androwish to crash: $new copy $src -scaleto 100 100 chw added on 2019-08-16 06:01:05: Check-in [a6855c2f6f] fixes the -scale vs. -scaleto ambiguity and seems to work on AndroWish. Further testing wanted, thus please update AndroWish from this APK: http://www.ch-werner.de/AndroWish/AndroWish-debug.apk However, I did not observe crashes using -scaleto. Maybe this is caused by your PNG file. Please send me the crashing PNG by private mail for further testing. john added on 2019-08-17 12:44:00: I can confirm that: -scale = works on both current Androwish, and also undroidwish (on OSX, that's where I tested) -scaleto = works on current Androwish. Doesn't exist as an option on undroidwish (on OSX, that's where I tested), but I suspect that's "as intended" as it is an older version. Thanks! john added on 2019-08-31 11:24:24: Wanted to report back that this fix DEFINITELY works, now tested in the field by users. Last week, a very cheap (USD$70) Chinese tablet with a non-standard resolution, and just 2gb of ram (Android 8.1), was able to resize all my PNGs as needed. It took a while, but it worked, with limited memory. My previous approach would have overwhelmed the machine's memory capacity. |