Why not register?


Post new topic Reply to topic  [ 15 posts ] 

All times are UTC [ DST ]

Author Message
PostPosted: Sat Jul 22, 2006 8:48 pm  Post subject: TIP: Cropping amazon images on the fly
Reply with quote
User avatar
Offline

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:
Image

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:

Image

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
 Profile  
PostPosted: Sat Jul 22, 2006 8:50 pm  Post subject:
Reply with quote
User avatar
Offline

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!

:beerchug:

_________________
Image
"SBiG: Bad Movie Download Central | Home of the ShitBusters" | White Wine FTW


Top
 Profile  
PostPosted: Sat Jul 22, 2006 9:17 pm  Post subject:
Reply with quote
User avatar
Offline

The Devil, Probably
Joined: Sun Mar 27, 2005 2:43 pm
Posts: 2250
Location: C.L.R.'s Grave, Hackensack, NJ
Whoa Great tip! *slaps forehead*

This should be added to the "how-to-post' thread.

Thanks vtwin0001!

_________________
SO BAD ITS GOOD! [bad-good.org]
Watch tits and gore and creepy dudes and pull out yer teeth and burn sensitive areas and drown while crying and fart babies!


Top
 Profile  
PostPosted: Sun Jul 23, 2006 10:29 am  Post subject:
Reply with quote
User avatar
Offline

Buried In The Backyard
Joined: Mon May 24, 2004 3:52 pm
Posts: 29
Nice one, thnx a lot

_________________
Image


Top
 Profile  
PostPosted: Sun Jul 23, 2006 1:13 pm  Post subject:
Reply with quote
User avatar
Offline

Lunatic Of Gods Creation
Joined: Mon Apr 05, 2004 8:52 pm
Posts: 1049
Location: Weaveworld
Yeah, great tip vtwin0001 :beerchug:

_________________
https://images.dead-donkey.com/images/bcopyoflgsingle1250eu7.jpg


Top
 Profile  
PostPosted: Sun Jul 23, 2006 2:06 pm  Post subject:
Reply with quote
User avatar
Offline

The Ancient One
Joined: Tue Dec 28, 2004 8:07 pm
Posts: 4935
Location: Always one step behind
Cool! :beerchug:


Top
 Profile  
PostPosted: Sun Jul 23, 2006 9:21 pm  Post subject:
Reply with quote
User avatar
Offline

Site Admin
Joined: Sat Nov 02, 2002 1:35 am
Posts: 19753
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 :matrix:

_________________
Mouse nipple for the win! Trackpoint or death!


Top
 Profile  
PostPosted: Mon Jul 24, 2006 5:43 am  Post subject:
Reply with quote
User avatar
Offline

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
 Profile  
PostPosted: Mon Jul 24, 2006 11:17 am  Post subject:
Reply with quote
User avatar
Offline

Site Admin
Joined: Sat Nov 02, 2002 1:35 am
Posts: 19753
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
 Profile  
PostPosted: Mon Jul 24, 2006 11:33 am  Post subject:
Reply with quote
User avatar
Offline

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
 Profile  
PostPosted: Mon Jul 24, 2006 12:02 pm  Post subject:
Reply with quote
User avatar
Offline

Site Admin
Joined: Sat Nov 02, 2002 1:35 am
Posts: 19753
Location: En España
i hate regex. :lol:

_________________
Mouse nipple for the win! Trackpoint or death!


Top
 Profile  
PostPosted: Mon Jul 24, 2006 9:37 pm  Post subject:
Reply with quote
User avatar
Offline

The Ancient One
Joined: Tue Dec 28, 2004 8:07 pm
Posts: 4935
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
 Profile  
PostPosted: Mon Jul 24, 2006 11:28 pm  Post subject:
Reply with quote
User avatar
Offline

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? :o


Top
 Profile  
PostPosted: Mon Jul 24, 2006 11:33 pm  Post subject:
Reply with quote
User avatar
Offline

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
 Profile  
PostPosted: Tue Jul 25, 2006 12:07 am  Post subject:
Reply with quote
User avatar
Offline

Site Admin
Joined: Sat Nov 02, 2002 1:35 am
Posts: 19753
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
 Profile  
Display posts from previous:  Sort by  

All times are UTC [ DST ]

Post new topic Reply to topic  [ 15 posts ] 


Who is online

Users browsing this forum: No registered users and 9 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

Search for:
Jump to:  
Frontpage / Forums / Scifi


What's blood for, if not for shedding?