Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,117 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,785 people online right now. Registration is fast and FREE... Join Now!




programming an app that will automatically crop pictures

 
Reply to this topicStart new topic

programming an app that will automatically crop pictures

abducted
6 Jun, 2007 - 01:57 AM
Post #1

New D.I.C Head
*

Joined: 6 Jun, 2007
Posts: 3


My Contributions
Hi!
I'm a total newbie and I'd like to know if it's difficult to make
a program that will batch crop panels from comic books.

Please look at this example :

IPB Image


I need a program that would automatically make five .jpg files from this single page.

Do you think it's possible ?

This post has been edited by abducted: 6 Jun, 2007 - 01:59 AM
User is offlineProfile CardPM
+Quote Post

Topher84
RE: Programming An App That Will Automatically Crop Pictures
6 Jun, 2007 - 06:47 AM
Post #2

D.I.C Head
Group Icon

Joined: 4 Jun, 2007
Posts: 232


Dream Kudos: 25
My Contributions
QUOTE(abducted @ 6 Jun, 2007 - 02:57 AM) *

Hi!
I'm a total newbie and I'd like to know if it's difficult to make
a program that will batch crop panels from comic books.

Please look at this example :

IPB Image


I need a program that would automatically make five .jpg files from this single page.

Do you think it's possible ?


Its possible im sure but wouldn't it be just as easy to just use photoshop to crop them yourself?
User is offlineProfile CardPM
+Quote Post

abducted
RE: Programming An App That Will Automatically Crop Pictures
6 Jun, 2007 - 07:33 AM
Post #3

New D.I.C Head
*

Joined: 6 Jun, 2007
Posts: 3


My Contributions
Yes in fact I've done a lot of crooping manually but I have many
many pages to process, so I really need a program !
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Programming An App That Will Automatically Crop Pictures
6 Jun, 2007 - 09:32 AM
Post #4

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,858



Thanked: 49 times
Dream Kudos: 550
My Contributions
QUOTE
Yes in fact I've done a lot of crooping manually but I have many
many pages to process, so I really need a program !

Agreed. So lets see... if someone knows anything about photoshop plug-ins (which I don't) I bet that such a program would not be too hard to do since photoshop has all the tools you would ever need/want.


Assuming that the images are not all broken up the same way...

To do it in C/C++ first find a good JPG library. Use it to load the image uncompressed into a buffer. Next you will look for horizontal/vertical lines of white (or white-ish) that will connect with the border. I would do this by selecting a grid of test points probably about 5-pixels wide. Then I would look for horizontal and vertical lines of white in these test points. If I am able to form a box large enough (and possibly not within another box) then I would copy that region to another buffer and save.

You know, if you don't know/want to learn C (which might take a while), and you are on a PC, I would use AutoHotkey. It is a macro scripting language that you can use with Photoshop (well you can automate any windows program with it). Basically you would do the same thing as above but you would move the mouse cursor to get the points, then move the mouse cursor to select etc... Definitely not as fast as the C/C++ program (which could probably do about an image a second or better) but it would allow you to sort of oversee the operation.

AutoHotkey has a rather easy learning curve if you already know how to program in a language as you can record keystrokes/mouse movement etc and then edit them -- so it lets you see the syntax for accomplishing a given task, then you just add in the variables and loops etc. to automate the process. You can add in key-combos to control the macro as it is running (so for instance pressing ctrl+z pauses the macro) so if you see someplace where the program is failing you can intervene.

I also think you can write scripts for PS in Python (I know you can in PSP 8 or better). Again this may be easier than C/C++.
User is offlineProfile CardPM
+Quote Post

abducted
RE: Programming An App That Will Automatically Crop Pictures
6 Jun, 2007 - 11:36 PM
Post #5

New D.I.C Head
*

Joined: 6 Jun, 2007
Posts: 3


My Contributions
thanks for your detailed reply.
I'll check AutoHotKey to see if it's difficult.
(I don't use photoshop and never tried macro scripting)
What I used for the cropping is a screen capture utility
and an image viewer. Can't be simpler than that but
it takes a lot of time.
After all, maybe the best thing I could do is
ask some expert programmer like you
to offer this service. I don't really want to learn
all this stuff to do a little program. So if anyone
here can do this for me, please let me know what would
be your price...
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:58PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month