| View previous topic :: View next topic |
| Author |
Message |
Krogdor
Joined: 18 Apr 2008 Posts: 1381 Location: The Interwebs
|
Posted: Sun Sep 14, 2008 8:37 pm Post subject: Picture Previewer |
|
|
Picture Previewer by Krogdor
Picture Previewer is a script designed to be compiled and used as a default (or optional) opener for picture files, which will quickly allow to view, crop, and convert picture to other formats. I initially designed this because I disliked waiting for more dense applications like Photoshop to open up just to view a simple picture.
Code is now hosted at AutoHotkey.net, can be found at [Picture Previewer.ahk]. Be sure to also download the necessary libraries, found at the bottom of this post.
Edit1: Thanks to everyone who helped me work about the bugs, it seems to be working pretty well now!
Edit2: [11/23/08]
Code revamped in many places, added support for animated .gifs (you can't crop them since you will lose the animation, but you can view them!) and converting to different formats when saving. Switched everything over to tic's much more complete GDI+ wrapper, and added support for changing the crop lines' color/transparency/thickness.
Edit3: [4/21/09]
Although I have been updating the script slowly but surely on my own computer, I haven't updated it on the forums in a long time. Some new features since the last update include some configurable values, support to crop pictures of any size, ability to zoom a picture to any percentage value, ability to use left/right arrow keys to cycle through images in the same directory as the one used to open the script, as well as a timer to do this automatically and support to have it jump to random images instead of going in order, to make a slideshow type effect. Also, support for transparent files was increased a bit, as they would get screwed up when dragging the crop box in previous versions. There was also some general cleanup of code, although it is still quite sloppy ( >.< ) and some bug fixes. This version, I have arbitrarily decided, will be called 1.1.0.0. Hopefully I'll keep track of versions in the future...
Tic's GDI+ library can be found [here]. Great work, tic!
PhiLho's code for displaying animated .gifs in a GUI can be found [here]. It requires a .dll file that can be found in that thread as well, but otherwise is a very handy bit of code. Thanks for that, PhiLho. Also, I suggest changing the file name to AniGif.ahk instead of Control_Gif.ahk to make it standard library compliant. (If you don't use standard library, you'll have to add the #Include lines at the top of the script for these two libraries)
Last edited by Krogdor on Sun May 03, 2009 9:53 pm; edited 15 times in total |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Sep 14, 2008 10:00 pm Post subject: |
|
|
bmp can show
but jpg and other type can't open. |
|
| Back to top |
|
 |
trik
Joined: 15 Jul 2007 Posts: 1299
|
Posted: Sun Sep 14, 2008 11:39 pm Post subject: |
|
|
| Quote: | | Code: | | Ext := SubStr(Param,InStr(Param, ".","",0)+1) |
|
This is very unreliable. I would reccomend using one of the methods mentioned in this topic. _________________ .com / .net |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1381 Location: The Interwebs
|
Posted: Mon Sep 15, 2008 1:14 am Post subject: |
|
|
How is it unreliable?
I've never liked SplitPath.
Also, new code posted that fixes Guest's problem as well as a small typo that caused a rather bad effect. |
|
| Back to top |
|
 |
wygd
Joined: 04 Nov 2007 Posts: 10
|
Posted: Mon Sep 15, 2008 6:32 am Post subject: |
|
|
thanks.
but your code have a bug
---------------------------
Error: Call to nonexistent function.
Specifically: GDIPlus_CropImage(FinalImage,PBitmap,(StartX > EndX ? EndX : StartX),(StartY > EndY ? EndY : StartY)...
Line#
081: if (ErrorLevel)
082: Goto,CropIt
083: if (SubStr(SaveFile, InStr(SaveFile, ".","",0)+1) != Ext)
084: SaveFile .= Ext
085: }
086: GDIPlus_LoadBitmap(PBitmap,Param)
087: GDIPlus_GetEncoderCLSID(Encoder, #GDIplus_mimeType_%Ext%)
---> 088: GDIPlus_CropImage(FinalImage,PBitmap,(StartX > EndX ? EndX : StartX),(StartY > EndY ? EndY : StartY),(StartX < EndX ? EndX-StartX : StartX-EndX),(StartY < EndY ? EndY-StartY : StartY-EndY))
089: EncoderParams := NONE
090: GDIPlus_SaveImage(FinalImage, SaveFile, Encoder, EncoderParams)
091: Gui,Destroy
092: GDIPlus_DisposeImage(PBitmap)
093: GDIPlus_Stop()
094: MsgBox,File cropped.
095: ExitApp
The program will exit.
---------------------------
GDIPlus_CloneBitmapArea(FinalImage,PBitmap,(StartX > EndX ? EndX : StartX),(StartY > EndY ? EndY : StartY),(StartX < EndX ? EndX-StartX : StartX-EndX),(StartY < EndY ? EndY-StartY : StartY-EndY))
 |
|
| Back to top |
|
 |
trik
Joined: 15 Jul 2007 Posts: 1299
|
Posted: Mon Sep 15, 2008 6:36 am Post subject: |
|
|
| wygd wrote: | | but your code have a bug |
It doesn't have a bug. You just don't have the proper files the script requires. As Krogdor says:
It can be found at this link:
http://www.autohotkey.com/forum/viewtopic.php?t=11860
Edit:
| Krogdor wrote: | How is it unreliable?
I've never liked SplitPath. |
Just read the posts in that thread, and you'll see.
Edit2: Type fix [Propper - Proper] _________________ .com / .net
Last edited by trik on Mon Sep 15, 2008 6:39 am; edited 3 times in total |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1381 Location: The Interwebs
|
Posted: Mon Sep 15, 2008 6:36 am Post subject: |
|
|
Whoops! I changed the name in my library because it's easier for me to remember, and I always forget to change it back. Thanks for pointing that out; it should work now.
Edit: Trikster, you're too fast for me!
Anyway, it was a bug on my part, as you can see from what I wrote above.
| Trikster wrote: | | Krogdor wrote: |
How is it unreliable?
I've never liked SplitPath. |
Just read the posts in that thread, and you'll see. |
I see nothing saying that using the string manipulation techniques is unreliable, just many other methods posted. |
|
| Back to top |
|
 |
DataLife
Joined: 27 Apr 2008 Posts: 232
|
Posted: Thu Sep 18, 2008 3:09 am Post subject: |
|
|
Not only did I have to download GDIplusWrapper.ahk, but also, DllCallStruct.ahk and BinaryEncodingDecoding.ahk.
I choose overwrite and it deletes my picture and does not save the cropped picture.
I choose "Choose File", then choose a location and give it a name and it does not create the file in that folder or anywhere on my pc that I can find.
I am using Windows Vista.
DataLife |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1381 Location: The Interwebs
|
Posted: Fri Sep 19, 2008 5:53 am Post subject: |
|
|
| Strange. I'm pretty sure it was working before... Anyhow, I changed it now and tested. Just had to replace the GDIPlus_CloneBitmapArea() call with its respective DllCall() and it worked. |
|
| Back to top |
|
 |
wygd
Joined: 04 Nov 2007 Posts: 10
|
Posted: Fri Sep 19, 2008 12:45 pm Post subject: |
|
|
| when I open the dynamics gif,but it show statics . |
|
| Back to top |
|
 |
DataLife
Joined: 27 Apr 2008 Posts: 232
|
Posted: Sun Sep 21, 2008 5:57 am Post subject: |
|
|
thanks Krogdor
This is a cool cropping program.
I copied your fixed code and it does work when I choose to create a new file, but when I try to overwrite the existing file it just deletes the existing file.
DataLife |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1381 Location: The Interwebs
|
Posted: Sun Sep 21, 2008 6:32 am Post subject: |
|
|
Hm. Well, I did say to be careful when overwriting!
Anyhow, I figured out the problem (I accidentally had it delete the file before loading it into the GDI+ >< ) but I switched over to using FileMove instead just because I figure it'll probably work better and reduce the chances of a file accidentally being deleted. |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1424
|
Posted: Sun Sep 21, 2008 12:03 pm Post subject: |
|
|
I think perhaps if you used the full gdi+ library then you could achieve a more polished program. You can test this out, but it still needs a lot more work: SAIRA-1.11.ahk
Drag and drop an image(s) onto the listview and then doubleclick it. Rest is self exaplanatory. I'm gonna add cropping, rotating, lightening/darkening, writing text to the image etc...... |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1381 Location: The Interwebs
|
Posted: Sun Sep 21, 2008 5:49 pm Post subject: |
|
|
Gosh, thanks for showing me up, tic
Anyway I'm not really interested in doing much more to it. Really just being able to quickly view the image is enough for me; the cropping was just something I wanted to do for the hell of it. |
|
| Back to top |
|
 |
DataLife
Joined: 27 Apr 2008 Posts: 232
|
Posted: Sun Sep 21, 2008 9:08 pm Post subject: |
|
|
Krogdor I like this program alot. It is simple, quick and does the job quite nicely.
It now overwrites the file as designed.
But, even after it successfully crops the image and overwrites the original I get the message "Sorry, some sort of error seems to have occurred."
DataLife |
|
| Back to top |
|
 |
|