473,732 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to rotate the image

Hi All,

Could anyone tell me how to rotate the image in javascript. Which
concepts I should concentrate to rotate the image

Dec 28 '05 #1
17 29411
http://www.kurs.horsesport.pl/inne/rv.html
Just to annoy PointedEars.

Dec 28 '05 #2

sa***********@s ify.com napisal(a):
Hi All,

Could anyone tell me how to rotate the image in javascript. Which
concepts I should concentrate to rotate the image


Okay, okay, I was cheating. That wasn't really rotation, just flipping.
Here you go, real rotation:
http://www.kurs.horsesport.pl/inne/rv2.html
Passed both Validator and Jigsaw, but tested only in FF1.5, don't have
anything else handy. You need to click "continue running script" when
prompted, then wait some...
Adding size detection and edge clipping left as an exercise to the
reader.

Seriously: I don't think there's any simple way to do what you want to
do. Most likely you need to get a base64-encoded image, decode it to an
array of integers/floats, process them according to the rules of given
image format to get a "bitmap" array, then pass them through the
rotation equations attached, reencode them back to GIF/JPG/whatever,
reencode them to base64, transform to a data: URI then hand the URI
over to an IMG tag. All in Javascript. Good luck writing JPEG
decompressor in Javascript. And of course it won't work in MSIE because
it has 256-char limit on all URIs.
In short: impossible.

Dec 28 '05 #3
except if you use the new canvas and svg. This way it should work in
firefox (both), safari (canvas only) and Opera (svg only).

IE also has enough activex at its disposal to rotate an image.

Cheers,

Dec 28 '05 #4
bw****@gmail.co m wrote:
sa***********@s ify.com napisal(a):
Could anyone tell me how to rotate the image in javascript. Which
concepts I should concentrate to rotate the image
Okay, okay, I was cheating. That wasn't really rotation, just flipping.
Here you go, real rotation:
http://www.kurs.horsesport.pl/inne/rv2.html
Passed both Validator and Jigsaw, but tested only in FF1.5, [...]


It takes more than a minute to be displayed by my Firefox 1.5 and locks
it afterwards.
You need to click "continue running script" when prompted, then wait
some...


Obviously the author of that HTML document does not have any clue.
PointedEars
Dec 28 '05 #5
sa***********@s ify.com wrote:
Could anyone tell me how to rotate the image in javascript.
You cannot do with JavaScript (or any other client-side applied
programming language in a UA environment) what you cannot do with
the UA. Rule of thumb: if the DOM of the UA does not provide the
means, JavaScript cannot provide it.
Which concepts I should concentrate to rotate the image


HTML DOMs, image filters (IE/Win only, 90° steps only AFAIK), and
your favorite image editor. SVG and the SVG DOMs if you want to
support them.
PointedEars
Dec 28 '05 #6

Thomas 'PointedEars' Lahn wrote:
bw****@gmail.co m wrote:
sa***********@s ify.com napisal(a):
Could anyone tell me how to rotate the image in javascript. Which
concepts I should concentrate to rotate the image


Okay, okay, I was cheating. That wasn't really rotation, just flipping.
Here you go, real rotation:
http://www.kurs.horsesport.pl/inne/rv2.html
Passed both Validator and Jigsaw, but tested only in FF1.5, [...]

It takes more than a minute to be displayed by my Firefox 1.5 and locks
it afterwards.


What did you expect with 10.000 DIVs acting as pixels? Get a faster
computer :P
You need to click "continue running script" when prompted, then wait
some...

Obviously the author of that HTML document does not have any clue.


The question was about rotating the image in Javascript. The script is
a correct answer, no matter how much you don't like it. Of course there
are better methods to rotate an image NOT using Javascript, or using
Javascript just in a support role, doing only some parameters passing
between modules of the browser. This one here performs actual rotation
in JS and uses an ugly, slow hack to display the result.

Suggest a faster, more efficient method of rotating an image in
Javascript. Feel free to use CSS, but don't use experimental features
like Canvas, SVG or non-standard or external ActiveX, Java etc.
Could anyone tell me how to rotate the image in javascript.

You cannot do with JavaScript (or any other client-side applied
programming language in a UA environment) what you cannot do with
the UA

But I just did.
Javascript is Turing-complete. That means. given required input and
output techniques, plus enough resources you can do EVERYTHING in it.
Some things are just harder than others, often because of I/O
shortcomings.
Someone talking about clue?

Dec 28 '05 #7

Thomas 'PointedEars' Lahn wrote:
sa***********@s ify.com wrote:
Could anyone tell me how to rotate the image in javascript.


You cannot do with JavaScript (or any other client-side applied
programming language in a UA environment) what you cannot do with
the UA. Rule of thumb: if the DOM of the UA does not provide the
means, JavaScript cannot provide it.
Which concepts I should concentrate to rotate the image


HTML DOMs, image filters (IE/Win only, 90° steps only AFAIK), and
your favorite image editor. SVG and the SVG DOMs if you want to
support them.


Indeed IE filters will work to rotate images along with text in a
division, at least in multiples of 90 degrees. See
http://elouai.com/javascript/javascr...age-rotate.php . You can test
their example on their page or download the code. Their test image is
quite small and simple. I have not tested this method on a large, very
detailed color image. Of course you will need a recent IE browser that
handles filters for this method to work.

Dec 28 '05 #8

cw******@yahoo. com wrote:
Thomas 'PointedEars' Lahn wrote:
sa***********@s ify.com wrote:
Could anyone tell me how to rotate the image in javascript.


You cannot do with JavaScript (or any other client-side applied
programming language in a UA environment) what you cannot do with
the UA. Rule of thumb: if the DOM of the UA does not provide the
means, JavaScript cannot provide it.
Which concepts I should concentrate to rotate the image


HTML DOMs, image filters (IE/Win only, 90° steps only AFAIK), and
your favorite image editor. SVG and the SVG DOMs if you want to
support them.


Indeed IE filters will work to rotate images along with text in a
division, at least in multiples of 90 degrees. See
http://elouai.com/javascript/javascr...age-rotate.php . You can test
their example on their page or download the code. Their test image is
quite small and simple. I have not tested this method on a large, very
detailed color image. Of course you will need a recent IE browser that
handles filters for this method to work.


I have put up a page at http://www.cwdjr.info/test/rotateimages.html .
I added just enough code to clean up to html 4.01 transitional. I added
a Microsoft conditional around all of the buttons so that the controls
only show on browsers for which they are likely to work(recent IE and
close relatives such as MSN 9). I used a fair sized image of about 42
KB. The response to the buttons is rapid. In addition to rotation by
multiples of 90 degrees, a morror image also can be produced. Most of
the script is hidden in the IE built-in filters. The only script you
have to write is in connection with the targets for the various
buttons.

There is another method to rotate your images by 180 degrees, but I do
not remember the details. About 2 years ago in a discussion group, a
lady described a problem that suddenly developed so that all images
displayed upside down on her monitor. There was much discussion about
monitor adjustments, but that did not help. It turned out that the
lady's children had been playing with the computer. There is some
obscure menu somewhere in the Windows OS that allows images to be
displayed rotated by 180 degrees. Her children apparently found out
about this from other children at school, and decided to have some fun
with their mother.

Dec 29 '05 #9
cw******@yahoo. com wrote:
I have put up a page at http://www.cwdjr.info/test/rotateimages.html .
I added just enough code to clean up to html 4.01 transitional.
You should add the system identifier not to trigger Compatibility Mode.
And you can make that HTML 4.01 Strict, from what I can see and what the
W3C Validator tells me, that would be Valid, too.
I added a Microsoft conditional around all of the buttons so that the
controls only show on browsers for which they are likely to work (recent
IE and close relatives such as MSN 9).
Yes, they are not shown in my Firefox 1.5 or Opera 8.5.
I used a fair sized image of about 42 KB. The response to the buttons is
rapid. In addition to rotation by multiples of 90 degrees, a morror image
also can be produced. Most of the script is hidden in the IE built-in
filters. The only script you have to write is in connection with the
targets for the various buttons.
But it is probably not necessary and makes less sense to refer to the `div'
element. Filters can be applied directly to the `img' element. At least
that worked for me with IE 4.0 filters ever since; I do not use DirectX
filters for backwards compatibility.

Referring to the `img' element would also allow you to refrain from using
the IE-proprietary referencing and use document.images['myimg'] instead,
provided that you gave the `img' the name `myimg'.
[...] There is some obscure menu somewhere in the Windows OS that allows
images to be displayed rotated by 180 degrees. Her children apparently
found out about this from other children at school, and decided to have
some fun with their mother.


:)
PointedEars
Dec 29 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
8241
by: Leo Koolsbergen | last post by:
Hallo, Maybe a very simpel problem, but I cannot find a solution. From a webcam I can retreive pictures, but as the cam is positioned upside down I have to rotate the (jpeg) pictures. I've searched about 50 javascripts sites, but I did not find what I am looking for. Can anyone help me with this? Greetings Leo Koolsbergen
7
2458
by: Showjumper | last post by:
Hi, I have developed an upload server controls to be reused over a number of projects. One of the tasks it needs to handle is to rotate an image. I want to accoplish this by checking the checkbox that is next to the file field. Once i browse for the file, i check the box to rotate and then upload. However i am unable to get it to rotate when the box is checked. It only rotates when i set a boolean (RotateImage) to true. Any ideas on how to...
1
3070
by: iwdu15 | last post by:
hi, im trying to rotate a gdi drawn object on my form with a keypress....forinstance when i push the down arrow, for it to rotate the object drawn until the top is down, or if i push the right arrow key, to rotate the object until its pointed to the right. i tried using a drawing matrix to accomplish this, but all it did was rotate my entire form (im drawing my object on the back of the form) and thats not what i need. I need it to rotate...
8
16812
by: Samuel Shulman | last post by:
Is it possible and how to rotate pictures in HTML document Thank you, Samuel
3
5120
by: Diego F. | last post by:
Hi all. I have a listview with images and my application must be able to rotate one image. I need a method to rotate 90 degrees rigth (i.e.). Is that possible? -- Regards, Diego F.
10
10957
by: Joey_Stacks | last post by:
Does anyone know of a scipt that will rotate random div layers on page refresh? I have a primary content area front and center on my site homepage, and I'd like to rotate various chunks of html (in div layers) each time a user reloads the page. Right now I'm resorting to a random image rotation (those scripts are a dime a dozen) on refresh, but it's far from ideal for what I'm trying to accomplish. Any help on this would be GREATLY...
2
3385
by: Dariusz.Donimirski | last post by:
I must rotate bmp using Xlib without change bmp's memory. If someone knows how I can do this, please help me. dariusz sorry about my english, I'm still learning
1
9447
Thekid
by: Thekid | last post by:
Hi, I have an image similar to a clock, with numbers and letters going around in a circle. I need to extract the numbers and letters from the image and have them print out in a straight line and in order from inner circle working out. Here is an example of the image: http://img296.imageshack.us/my.php?image=screenimageqk9.jpg Since the characters in the image will be different each time I am starting with a screenshot, then I think I should...
0
1725
by: harryusa | last post by:
I am experimenting with the rotate function and so far I can't get my code to return anything but the URL of my script. Here it is: <?php // The file you are rotating $image = 'halloween.jpg'; //How many degrees you wish to rotate $degrees = 180;
0
8774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9307
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9235
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.