Rotate an image?

M

Martin

Is it possible to display an image (a .gif or a .jpg or a .png) such
that it is rotated some specified number of degrees? Or does the image
itself have to be modified?
 
D

Dylan Parry

Spake Martin unto thee:
Is it possible to display an image (a .gif or a .jpg or a .png) such
that it is rotated some specified number of degrees? Or does the image
itself have to be modified?

With HTML, no. You could do it with some server side programming, but it
would be easier to do it yourself using your favourite image editor.
 
M

Martin

With HTML, no. You could do it with some server side programming, but it
would be easier to do it yourself using your favourite image editor.

Actually, some server-side programming is already being used in the
situation I'm taking about. The page in question here is being
generated by a PHP script. But, the only way I can see to rotate the
image is by actually modifying the image - and I'm having some
problems with that. Thus, my question.

Do I understand you to mean that with some server-side programming the
image could be displayed at an angle without actually modifying the
image?
 
D

Dylan Parry

Spake Martin unto thee:
Do I understand you to mean that with some server-side programming the
image could be displayed at an angle without actually modifying the
image?

Yes, although I've not done what you want specifically, it is possible for
PHP to send back an image header (eg. image/jpeg) and open up an existing
image to base its content on. You should be able to find some tutorials
showing how to do this.

In order to use the image you would simply refer to the PHP file in the
image element (eg. <img src="image.php" ... />). You could then pass
variables to the PHP to specify the angle of rotation and the actual base
image to use.

Again, I couldn't tell you the exact code to use as I haven't done this
before, but a search should find you enough info to get started. Of
course, as I said earlier, it might be less hassle to do it manually ;)
 
S

SpaceGirl

Martin said:
Is it possible to display an image (a .gif or a .jpg or a .png) such
that it is rotated some specified number of degrees? Or does the image
itself have to be modified?

Yes. Stick it in Flash :) You have complete programmatic control over
every property of the image then.

--


x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #
 
D

Dylan Parry

Spake SpaceGirl unto thee:
Yes. Stick it in Flash :) You have complete programmatic control over
every property of the image then.

So you are suggesting the OP change from using a file type that every
graphical browser can display without having any external plugin, to using
a format that is proprietary and won't work in any browser without a
plugin? :\
 
M

Martin

Spake Martin unto thee:


Yes, although I've not done what you want specifically, it is possible for
PHP to send back an image header (eg. image/jpeg) and open up an existing
image to base its content on. You should be able to find some tutorials
showing how to do this.

In order to use the image you would simply refer to the PHP file in the
image element (eg. <img src="image.php" ... />). You could then pass
variables to the PHP to specify the angle of rotation and the actual base
image to use.

Again, I couldn't tell you the exact code to use as I haven't done this
before, but a search should find you enough info to get started. Of
course, as I said earlier, it might be less hassle to do it manually ;)


Thanks for the tip - I'll see what I can find out.
 
S

SpaceGirl

Dylan said:
Spake SpaceGirl unto thee:




So you are suggesting the OP change from using a file type that every
graphical browser can display without having any external plugin, to using
a format that is proprietary and won't work in any browser without a
plugin? :\

No... I was just offering one solution. 90% of machines have Flash
installed (probably as many people who have JS enabled) so it was a fair
suggestion :)

--


x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #
 
D

Default User

Dylan Parry wrote:

[image rotation with PHP]
Again, I couldn't tell you the exact code to use as I haven't done
this before, but a search should find you enough info to get started.
Of course, as I said earlier, it might be less hassle to do it
manually ;)

I'd recommend the newsgroup comp.lang.php for heavy-duty questions.



Brian
 
M

Martin

I'd recommend the newsgroup comp.lang.php for heavy-duty questions.

Yeah - actually, I've already posted a question there about the
problems I'm having with the "imagerotate" function (which led me to
seeing if there was another way to do this).

I've been googling for the last couple of hours but haven't come up
with much. :(
 
J

Jim Higson

Martin said:
Is it possible to display an image (a .gif or a .jpg or a .png) such
that it is rotated some specified number of degrees? Or does the image
itself have to be modified?

Will you require the image to be rotated via user input, or do you already
know which angles it will be drawn at so you can provide pre-roated images?

You could create a load of pre-rotated images (360 of them, say) using PHP
scripting for the GIMP, then send the user the one they want when the page
loads.
 
W

WebcastMaker

So you are suggesting the OP change from using a file type that every
graphical browser can display without having any external plugin, to using
a format that is proprietary and won't work in any browser without a
plugin? :\

Uh, yea... (flopping my head back and forth), that is a viable option.
And if the op's need is for real time image manipulation, then yes,
Flash is not only an option, it is probably the BEST option.
 
M

Martin

Will you require the image to be rotated via user input, or do you already
know which angles it will be drawn at so you can provide pre-roated images?

You could create a load of pre-rotated images (360 of them, say) using PHP
scripting for the GIMP, then send the user the one they want when the page
loads.

No, user input is not a factor. In afct, a series of pre-rotated
images is exactly what I had in mind.

I thought I could use the "gd" functions in PHP to create them (I
don't need anywhere near 360 of them - maybe 6 - 8), but I have not
been able to get past a couple of problems with the "imagerotate"
function. But, even if I would get that to work, I'll still have to
deal with the fact that a rotated image will be much larger than what
I would like.

The image I want to rotate is simply a long, narrow rectangle (roughly
the proportions of a pen or a pencil). When it's displayed on the web
page, it needs to be clickable - thus my desire to display it as an
<img>. If I create an image with the narrow rectangle rotated then the
entire image becomes relatively large (eg: a 2" x .25" rectangle, when
rotated at 45 degrees, would require an area more than 2" x 2") and
the background area is also clickable (even though it would be
transparent). That all led to my original question here about how I
might rotate the long, narrow image without actually changing it in
any manner.

FWIW, I can do exactly what I'm talking about with VML (Vector Markup
Language) but that works only in IE and I want something that can be
viewed in any browser. (And, alluding to another branch of this thread
- without any plug-ins).

Any other thoughts or suggestions will be greatly appreciated - I'm
pretty much stumped as to how to do this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top