Sign Up
OpenID
Google
Yahoo!
Facebook
Ning
Discuss
New Topic
Categories
Forum
Debate
Languages
English
Finnish
Arabic
Italian
Korean
French
Chinese(Traditional)
Chinese(Simplified)
Swedish
Czech
Hindi
Dutch
Norwegian
Russian
Croatian
German
Japanese
Bulgarian
Portuguese
Chinese
Spanish
Greek
Login
Ok
Ads
Ask a Question
enter your topic here...
Welcome New Members!
Hot Topics
array
code
column
content
Custom
database
drupal
element
field
file
form
function
index
jquery
module
MySQl
node
page
PHP
query
server
something
SQL
string
table
theme
time
user
VALUE
way
Reason
How do I manually create thumbnails of an image?
ArtPie
How do I manually create thumbnails of an image? I 'm really stuck on this one.
I will manually create 10 PR9 Top Quality SEO Friendly Backlinks from 10 Unique Pr 9 Authority Sites + Panda and Penguin Friendly + indexing just
for
$10
In
Wordpress
|
1 Reply
|
2906 Views
|
1 month ago
manually
create
image
really
stuck
Report Abuse
Email
Add to Favorites
Rate Now:
Average Rating:
0.00 / 0
ratings
Replies:
Guest
Here is a function to create thumbnails using PHP and GD.
function
createthumb
(
$name
,
$filename
,
$new_w
,
$new_h
)
{
$system
=
explode
(
'.'
,
$name
)
;
if
(
preg_match
(
'/jpg|jpeg/'
,
$system
[
1
]
)
)
{
$src_img
=
imagecreatefromjpeg
(
$name
)
;
}
if
(
preg_match
(
'/png/'
,
$system
[
1
]
)
)
{
$src_img
=
imagecreatefrompng
(
$name
)
;
}
$old_x
=
imageSX
(
$src_img
)
;
$old_y
=
imageSY
(
$src_img
)
;
if
(
$old_x
>
$old_y
)
{
$thumb_w
=
$new_w
;
$thumb_h
=
$old_y
*
(
$new_h
/
$old_x
)
;
}
if
(
$old_x
<
$old_y
)
{
$thumb_w
=
$old_x
*
(
$new_w
/
$old_y
)
;
$thumb_h
=
$new_h
;
}
if
(
$old_x
==
$old_y
)
{
$thumb_w
=
$new_w
;
$thumb_h
=
$new_h
;
}
$dst_img
=
ImageCreateTrueColor
(
$thumb_w
,
$thumb_h
)
;
imagecopyresampled
(
$dst_img
,
$src_img
,
0
,
0
,
0
,
0
,
$thumb_w
,
$thumb_h
,
$old_x
,
$old_y
)
;
if
(
preg_match
(
"/png/"
,
$system
[
1
]
)
)
{
imagepng
(
$dst_img
,
$filename
)
;
}
else
{
imagejpeg
(
$dst_img
,
$filename
)
;
}
imagedestroy
(
$dst_img
)
;
imagedestroy
(
$src_img
)
;
}
Use it like this:
createthumb
(
'pics/apple.jpg'
,
'thumbs/tn_apple.jpg'
,
100
,
100
)
;
Reply to Answer
1 month ago
Report Abuse
By
Guest
Rate Now:
Average Rating:
0.00 / 0
ratings
Replied by
Guest
1 month ago
Your Response:
Join
Login
Related Questions
Is there a class that can be used to create an image?
1 Answer | 591 Views
How To Add Watermark To An Image with PHP and Imagepng
4 Answers | 10615 Views
Create nodes from a google calender feed in drupal 7?
0 Answers | 3264 Views
Can I not just do $_FILES['image']=$image and put $image into a database?
0 Answers | 3361 Views
When to create a custom module and set of db tables vs using CCK?
0 Answers | 3375 Views