Why not register?
|
Page 1 of 1
|
[ 15 posts ] |
|
Author |
Message |
vtwin0001
|
Posted: Sat Jul 22, 2006 8:48 pm Post subject: TIP: Cropping amazon images on the fly |
|
Demon Of The Abyss Joined: Thu Jun 02, 2005 11:44 pm Posts: 1522
|
Just found this tip @ clan-sudamerica and wanted to shre it with you:
When you're trying to post an image from amazon, you get those dreaded white things on the sides... like this:
Original:
Well... let's see the code:
Code: | http://ec1.images-amazon.com/images/P/B00005PJ6N.01._SS500_SCLZZZZZZZ_V1056698532_.jpg |
By manipulating the code, you can easily crop the image to get only the cover like this:
The differences:
all are http://ec1.images-amazon.com
Original Code:
/images/P/B00005PJ6N. 01._SS500_SCLZZZZZZZ _V1056698532_.jpg
Cropped code:
/images/P/B00005PJ6N.02.LZZZZZZZ.jpg
The first underlined part was replaced by a 02
The second underlined part was just erased.
Check it out and enjoy
|
|
Top |
|
|
pure
|
Posted: Sat Jul 22, 2006 8:50 pm Post subject: |
|
The Devil, Probably Joined: Fri Jan 06, 2006 1:58 pm Posts: 1940 Location: Just Follow The Stench
|
Thanks for the tip!
Will check it out!
_________________
"SBiG: Bad Movie Download Central | Home of the ShitBusters" | White Wine FTW
|
|
Top |
|
|
GrindCallus
|
Posted: Sat Jul 22, 2006 9:17 pm Post subject: |
|
The Devil, Probably Joined: Sun Mar 27, 2005 2:43 pm Posts: 2250 Location: C.L.R.'s Grave, Hackensack, NJ
|
|
Top |
|
|
warre
|
Posted: Sun Jul 23, 2006 10:29 am Post subject: |
|
Buried In The Backyard Joined: Mon May 24, 2004 3:52 pm Posts: 29
|
Nice one, thnx a lot
_________________
|
|
Top |
|
|
killingjokezzz
|
Posted: Sun Jul 23, 2006 1:13 pm Post subject: |
|
Lunatic Of Gods Creation Joined: Mon Apr 05, 2004 8:52 pm Posts: 1049 Location: Weaveworld
|
Yeah, great tip vtwin0001
_________________ https://images.dead-donkey.com/images/bcopyoflgsingle1250eu7.jpg
|
|
Top |
|
|
^Rogue^
|
Posted: Sun Jul 23, 2006 2:06 pm Post subject: |
|
The Ancient One Joined: Tue Dec 28, 2004 8:07 pm Posts: 4952 Location: Always one step behind
|
Cool!
|
|
Top |
|
|
spudthedestroyer
|
Posted: Sun Jul 23, 2006 9:21 pm Post subject: |
|
Site Admin Joined: Sat Nov 02, 2002 1:35 am Posts: 19754 Location: En España
|
I'll see if i can get the board to do it automatically. I'm just shit at regex so it will take me a while to figure out a string that works
_________________ Mouse nipple for the win! Trackpoint or death!
|
|
Top |
|
|
Vae Victis
|
Posted: Mon Jul 24, 2006 5:43 am Post subject: |
|
Demon Of The Abyss Joined: Tue Jun 14, 2005 8:01 pm Posts: 1130
|
prob something like this:
Code: | /images/([a-zA-Z])/([0-9a-zA-Z]*).01._SS500_SC([a-zA-Z]{8})_(?:[0-9a-zA-Z]*)_.jpg |
and the next line shows how to build the new string. Code: | /images/&1/&2.02.&3.jpg |
Nice program I use for testing regexps is: regex coach
http://weitz.de/regex-coach/
if you need an explanation for the regexp let me know.
|
|
Top |
|
|
spudthedestroyer
|
Posted: Mon Jul 24, 2006 11:17 am Post subject: |
|
Site Admin Joined: Sat Nov 02, 2002 1:35 am Posts: 19754 Location: En España
|
Hehe, well you were close but PHP is a retarded relation to pearl so I got this one in the end then fell asleep:
Code: | $ret = preg_replace("#/images/([a-zA-Z])/([0-9a-zA-Z]*).01._SS500_SC([a-zA-Z]{8})_(?:[0-9a-zA-Z]*)_.jpg#is","/images/\\1/\\2.02.\\3.jpg", $ret); |
//1 are the return types of the brackets in php
and you need # to start and stop it for whatever reason, i don't really know why i just noticed all the others began and ended like that.
anyway, I moved this to site development. Thank for the info vt and vae
_________________ Mouse nipple for the win! Trackpoint or death!
|
|
Top |
|
|
Vae Victis
|
Posted: Mon Jul 24, 2006 11:33 am Post subject: |
|
Demon Of The Abyss Joined: Tue Jun 14, 2005 8:01 pm Posts: 1130
|
Quote: | and you need # to start and stop it for whatever reason, i don't really know why i just noticed all the others began and ended like that. |
The reason is that you need to enclose the regexp with 2 symbols, doesn't need to be # but can also be /
You also need to backslash(escape) those symbols if you use them in your regexp.
Just for the fun of it, if you would use / instead of # it would be:
Code: | /\/images\/([a-z])\/([0-9a-z]*).01._SS500_SC([a-z]{8})_(?:[0-9a-z]*)_.jpg/is |
If you are using is (#is) you can shorten the regexp by: (drop the A-Z) Code: | $ret = preg_replace("#/images/([a-z])/([0-9a-z]*).01._SS500_SC([a-z]{8})_(?:[0-9a-z]*)_.jpg#is","/images/\\1/\\2.02.\\3.jpg", $ret); |
i stands for case insensitive.
|
|
Top |
|
|
spudthedestroyer
|
Posted: Mon Jul 24, 2006 12:02 pm Post subject: |
|
Site Admin Joined: Sat Nov 02, 2002 1:35 am Posts: 19754 Location: En España
|
i hate regex.
_________________ Mouse nipple for the win! Trackpoint or death!
|
|
Top |
|
|
^Rogue^
|
Posted: Mon Jul 24, 2006 9:37 pm Post subject: |
|
The Ancient One Joined: Tue Dec 28, 2004 8:07 pm Posts: 4952 Location: Always one step behind
|
Here's a solution a friend of mine came up with (Greek to me):
Code: | $text = preg_replace("!([a-zA-Z0-9\-\_\.]*amazon\.com\/.+\/)([a-zA-Z0-9]+)\.01.+\_SC([a-zA-Z0-9]+)\_.+(\.jpg)!","\\1\\2.02.\\3\\4", $text); |
|
|
Top |
|
|
unskinnyboy
|
Posted: Mon Jul 24, 2006 11:28 pm Post subject: |
|
Servant Of The Dead Donkey Joined: Sun Oct 16, 2005 6:57 am Posts: 96
|
Am I the only one who finds no difference from the 2 pictures?
|
|
Top |
|
|
vtwin0001
|
Posted: Mon Jul 24, 2006 11:33 pm Post subject: |
|
Demon Of The Abyss Joined: Thu Jun 02, 2005 11:44 pm Posts: 1522
|
i think spud implemented succesfully the code
_________________ https://images.dead-donkey.com/images/menu7ax3100x56dl1.jpg
|
|
Top |
|
|
spudthedestroyer
|
Posted: Tue Jul 25, 2006 12:07 am Post subject: |
|
Site Admin Joined: Sat Nov 02, 2002 1:35 am Posts: 19754 Location: En España
|
Yes the fact that you don't see a difference is a good thing, means the script works.
_________________ Mouse nipple for the win! Trackpoint or death!
|
|
Top |
|
|
|
Page 1 of 1
|
[ 15 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 32 guests |
|
|
|
You cannot post new topics in this forum You cannot 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
|
|