AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Picture Previewer
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Krogdor



Joined: 18 Apr 2008
Posts: 1381
Location: The Interwebs

PostPosted: Sun Sep 14, 2008 8:37 pm    Post subject: Picture Previewer Reply with quote

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
View user's profile Send private message AIM Address
Guest






PostPosted: Sun Sep 14, 2008 10:00 pm    Post subject: Reply with quote

bmp can show
but jpg and other type can't open.
Back to top
trik



Joined: 15 Jul 2007
Posts: 1299

PostPosted: Sun Sep 14, 2008 11:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1381
Location: The Interwebs

PostPosted: Mon Sep 15, 2008 1:14 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
wygd



Joined: 04 Nov 2007
Posts: 10

PostPosted: Mon Sep 15, 2008 6:32 am    Post subject: Reply with quote

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))

Laughing
Back to top
View user's profile Send private message
trik



Joined: 15 Jul 2007
Posts: 1299

PostPosted: Mon Sep 15, 2008 6:36 am    Post subject: Reply with quote

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:

Krogdor wrote:
The script relies on PhiLho's GDIplus wrapper


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
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1381
Location: The Interwebs

PostPosted: Mon Sep 15, 2008 6:36 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
DataLife



Joined: 27 Apr 2008
Posts: 232

PostPosted: Thu Sep 18, 2008 3:09 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Krogdor



Joined: 18 Apr 2008
Posts: 1381
Location: The Interwebs

PostPosted: Fri Sep 19, 2008 5:53 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
wygd



Joined: 04 Nov 2007
Posts: 10

PostPosted: Fri Sep 19, 2008 12:45 pm    Post subject: Reply with quote

when I open the dynamics gif,but it show statics .
Back to top
View user's profile Send private message
DataLife



Joined: 27 Apr 2008
Posts: 232

PostPosted: Sun Sep 21, 2008 5:57 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Krogdor



Joined: 18 Apr 2008
Posts: 1381
Location: The Interwebs

PostPosted: Sun Sep 21, 2008 6:32 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
tic



Joined: 22 Apr 2007
Posts: 1424

PostPosted: Sun Sep 21, 2008 12:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1381
Location: The Interwebs

PostPosted: Sun Sep 21, 2008 5:49 pm    Post subject: Reply with quote

Gosh, thanks for showing me up, tic Embarassed

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
View user's profile Send private message AIM Address
DataLife



Joined: 27 Apr 2008
Posts: 232

PostPosted: Sun Sep 21, 2008 9:08 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group