Click here to Skip to main content
Licence 
First Posted 28 Aug 2003
Views 83,363
Bookmarked 19 times

Split Image

By Per S | 28 Aug 2003
Displaying a split image using a table
2 votes, 13.3%
1
2 votes, 13.3%
2
1 vote, 6.7%
3
5 votes, 33.3%
4
5 votes, 33.3%
5
3.50/5 - 15 votes
μ 3.40, σa 2.55 [?]

Sample screenshot

Introduction

You can create some nice pictures by splitting them up into smaller images. Doing this in Photoshop and keeping the proportions isn't easy (I'm no photoshop guru), instead you can do it using a table. The code below creates the image of the sailboat.

How it's done

The image is loaded into a table as a background image

<style>
#splitimg {
    background:url(http://soderlind.no/s/splitimg/sailboat.gif);
    width:  300px;
    height: 400px;
}
</style>
.
.
.
<table id="splitimg"> 

Or, if you don't like to use CSS:

<table background="http://soderlind.no/s/splitimg/sailboat.gif" <BR>    width="300" height="400">

Next,  place a grid on top of the image using table rows and colums.

<tr>
    <td class="transp"> </td>
</tr>
<tr>
    <td class="hide"></td>
</tr>
<tr>
    <td class="transp"> </td>
</tr>
<tr>
    <td class="hide"></td>
</tr>
<tr>
    <td class="transp"> </td>
</tr>

A TD with a background color will hide that part of the image:

.hide {
    background-color:  #FFFFFF;
    width:  10px;
    height: 10px;
}
A TD without background color will be transparent:
.transp {
    border: 2px solid #000000;
    width:  300px;
    height: 113px;
}

Complete sample code:

<!-- Insert the STYLE code into the <HEAD> section of your page -->

<style>
#splitimg {
    background:url(http://soderlind.no/s/splitimg/sailboat.gif);
    width:  300px;
    height: 400px;
}

.hide {
    background-color:  #FFFFFF;
    width:  10px;
    height: 10px;
}

.transp {
    border: 2px solid #000000;
    width:  300px;
    height: 113px;
}

</style>

<!-- Insert the TABLE code into the <BODY> section of your page -->

<table id="splitimg" cellspacing="0" cellpadding="0" border="0">
<tr>
	<td class="transp"> </td>
</tr>
<tr>
	<td class="hide"></td>
</tr>
<tr>
	<td class="transp"> </td>
</tr>
<tr>
	<td class="hide"></td>
</tr>
<tr>
	<td class="transp"> </td>
</tr>
</table>

Split image tool

Doing this by hand isn't easy, so I created a tool you can use - http://soderlind.no/s/splitimg/default.asp 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Per S

Web Developer

Norway Norway

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalhaha,I know what's your meaning PinsussTommyWOo.cn16:47 7 Sep '03  
QuestionPurpose? Pinmemberchong_lim17:15 30 Aug '03  
AnswerRe: Purpose? PinmemberPer Soderlind2:23 31 Aug '03  
QuestionHow does the other side look like... PinsitebuilderUwe Keim23:15 29 Aug '03  
GeneralI like the idea ... PinmemberSébastien Lorion22:49 29 Aug '03  
Generaltable tag PinmemberRui Dias Lopes9:16 29 Aug '03  
GeneralRe: table tag PinmemberSven Axelsson13:52 29 Aug '03  
GeneralRe: table tag PinmemberRui Dias Lopes0:54 30 Aug '03  
GeneralRe: table tag PinmemberSven Axelsson1:34 30 Aug '03  
GeneralRe: table tag PinmemberPer Soderlind8:31 31 Aug '03  
GeneralRe: table tag PinmemberStephane Rodriguez.21:12 29 Aug '03  
GeneralInteresting idea... PinmemberRyan Binns5:17 29 Aug '03  
GeneralRe: Interesting idea... PinmemberPer Soderlind6:03 29 Aug '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120209.1 | Last Updated 29 Aug 2003
Article Copyright 2003 by Per S
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid