AutoHotkey Community

It is currently May 26th, 2012, 12:18 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Picture Previewer
PostPosted: September 14th, 2008, 9:37 pm 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
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 May 3rd, 2009, 10:53 pm, edited 15 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 14th, 2008, 11:00 pm 
bmp can show
but jpg and other type can't open.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 15th, 2008, 12:39 am 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
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.

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 15th, 2008, 2:14 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 15th, 2008, 7:32 am 
Offline

Joined: November 4th, 2007, 5:48 pm
Posts: 10
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))

:lol:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 15th, 2008, 7:36 am 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
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]

_________________
Religion is false. >_>


Last edited by trik on September 15th, 2008, 7:39 am, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 15th, 2008, 7:36 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 18th, 2008, 4:09 am 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 19th, 2008, 6:53 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 19th, 2008, 1:45 pm 
Offline

Joined: November 4th, 2007, 5:48 pm
Posts: 10
when I open the dynamics gif,but it show statics .


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2008, 6:57 am 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2008, 7:32 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2008, 1:03 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
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......


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2008, 6:49 pm 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Gosh, thanks for showing me up, tic :oops:

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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 21st, 2008, 10:08 pm 
Offline

Joined: April 27th, 2008, 5:28 pm
Posts: 489
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: bbwht, oldbrother and 59 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group