JavaScript - Detect The Image Size (dimensions) From An Image Url And Related For Ebay
QUESTION 1:
Hello. I would like to know if this is possible with Javascript, and if yes, if someone can please provide me with the code or point me in the right direction. Let me start of by saying that this is for an eBay listing. I know that they accept basic / limited javascript and if what I am asking is possible, I hope that it can work on eBay listings. I would like to know if it's possible to determine the dimensions of an image with Javascript from an Image url, and to then resize it or not based on the the size of the image. So, let's say this is the URL: www.adomainname.com/image.jpg and let's say that image is 1400 px x 1400 px. I would first like the javascript code to detect that size. I also would like the maximum dimension for any side of the image to be 600 px. If both sides of the image are over 600 px, for both sides to be reduced proportionally to 600 px or lower. If any one side of the image is larger than 600 px, the image is to be resized to 600 px or lower. If both sides are under 600 px, the image is to not be reduced. It would also be nice if it can detect whether the image is portion or landscape based on I guess the larger side, because an image at 600 px in height might be too big, but in width might be o.k. So, in this example (the 1400 px by 1400 px), the image is to be resized to 600 px x 600 px. For an image that's 300 px x 500 px, it should remain as such. For an image that's 400 px x 700 px, it should be resized to 400 / (700 / 600) px by 600 px, which is approximately 343 px x 600 px. I have looked a bit into this and I see things being mentioned about the image being loaded first completely on the screen, or about using server side language like PHP, and so on, but like I said, keep in mind that this is for eBay, and so I am limited. Note: The part that I am most interested in is in being able to detect the size / dimensions of the image. QUESTION 2: On a side note, does anyone know if it's possible to have a Javascript enlarging function for images, in which when one clicks on an image, it is enlarged, but either in a popup window that's smaller than the one behind it, and possibly centered, or by making the background go dark and then bringing up the enlarged image (is the latter done with Javascript; I have seen this effect for a while now and have always wondered.) Similar Tutorialsi have image button i need to display image .if the size of the image button is 100*100 and image size is 50*50 .the remaining space of the image button should be empty.the image should not stretch. can any one guide me i am new to programming Thanks in advance!!! Hi I would appreciate a pointer in the right direction for a script I require. I will have two text boxes that will accept numeric values and an image. What I need is if the user change the value of box 1, the value in box 2 will automatically update depending on the pixel dimensions of the image and vice versa. Basically I need to automatically calculate the pixel ratio of an image and then use that value to multiply by the user inputted size. Any ideas? Rob I am new to this forum and self taught (amateur) programmer. I am making my eBay template for items that I sell (vintage clothing). I use the auction management system Blackthorne. I am trying to make my images swap over like this seller: Image rollover i want to replicate. It is not difficult to this in most listings but because I use Blackthorne, I have to put tags rather than the exact url of the image in my template. for example, [[picture1]], [[picture2]], etc. I do have a script which works so that the user can click on the photo to change it but I would prefer it if they could mouseover. The script I have been given to use is on this link: picture show script Thanks in advance. Hi, I am a Javascript newbie and I am trying to add a Javascript image application (called "HighSlide JS: http://highslide.com/#examples) to eBay listings. I am somewhat experienced with HTML and computers in general, but this javascript is all very confusing to me. My question is quite broad: How can I get this HighSlides script to show my images on my eBay listings? I am having trouble figuring out how to upload images to FTP servers or something, so that the script can use my images. I have Windows 7, and I do have Expression Web, if that means anything! I would be extremely grateful for any help! Thanks in advance! I have an iframe that is a specific height and width. I want to detect whenever the the iframe is no longer exactly the height i set it to. If a user has CSS turned off for example the iframe will be in default height and width. I want to detect that. This is how you'd normally do it but this only returns the original size (try with 'no style' in Firefox): Code: function getSize() { alert('height is now '+document.getElementById("Iframemain").height) alert('height is now '+document.getElementById("Iframemain").width) } Is it possible? I have a button (in html) and I want the center of the button to be on the center of the line I'm typing on... I was just putting it inside a span and then using this code to move it down. Code: <span style="position:relative; bottom:-10;"> It worked great! But... once I started allowing my users to change the font sizes the buttons got bigger and they needed to be moved down further... if the font size was +1: Code: <font size="+1"><span style="position:relative; bottom:-10;"> if the font size was +6: Code: <font size="+6"><span style="position:relative; bottom:-27.5;"> So is there a way in javascript to detect the current font size and then adjust the span position based off of that? If I can just get the number of the current font size I can do all the rest of the coding, I just need a way to figure out the current font size and put it in a variable... I was thinking of using something like 1.0em so that it stays the same but then we have a basis of measuring off of but I have no clue.. I'm fairly new to javascript. Thanks! I have a goal in mind, and that is to get the width & height of a <DIV> tag in one document and insert them into another document...all on the same domain. It sounds like a simple task, but in case more detail is needed, let me explain: I have a page called 'demo.html' which launches a page called 'gallery/archive_iframe.html' via Shadowbox as an iFrame. The problem is that 'gallery/archive_iframe.html' slightly differs in dimension on every browser and screen resolution. I want to have the iFrame's size detected every time it launches so Shadowbox can get solid dimensions to display it without scrollbars. You can see the current (fixed size) example at: http://www.mikegermond.com/demo.html Click on the 'Video Archive' image. Here is the code I would like to insert the dimensions in to: Code: <A HREF="/gallery/archive_iframe.html" rel="shadowbox;width= ??? ;height= ??? " class="imgLink" title="Video Archive"><img src="gallery/videoarchive_thm.jpg" alt="Launch Video Archive (popup window)" width="260" height="162" border="0" /></A> Hi all, I'm trying to detect the screen resolution of the client's computer. I've been using the following example: PHP Code: <HTML> <TITLE>screen resolution</TITLE> <HEAD> </HEAD> <BODY> <?php if(isset($_COOKIE["users_resolution"])) $screen_res = $_COOKIE["users_resolution"]; else //means cookie is not found set it using Javascript { ?> <script language="javascript"> <!-- writeCookie(); function writeCookie() { var today = new Date(); var the_date = new Date("December 31, 2023"); var the_cookie_date = the_date.toGMTString(); var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height; var the_cookie = the_cookie + ";expires=" + the_cookie_date; document.cookie=the_cookie location = 'get_resolution.php'; } //--> </script> <?php } ?> <?php echo "Your screen resolution is set at ". $screen_res; ?> </BODY> </HTML> This all works fine except it doesn't factor in if the user changes their screen resolution for any reason. In my own experience I often change resolutions depending on what I'm doing. I posted the question in there PHP forum http://www.codingforums.com/showthread.php?t=192440 but it looks like I'm needing a pure JS solution. Fou-Lu kindly offered their approach: Quote: Originally Posted by Fou-Lu As for detecting changes, only javascript can do that. Instead of using PHP to check that, use pure javascript and alter you're function to check if its cookies are not existant OR the sizes have changed compared to the cookie, update them. And as mentioned, they will still only take effect after the next page load. Could someone help me with this? I want the end result to be something like http://www.screenresolution.org/ in that if you change your resolution then refresh the page, the screen resolution is updated. I hope I've explained this clearly? Let me know if you need any more information. The next challenge is then getting my PHP functions to work in the following manner: PHP Code: if ($screen_width > 1024){ function('1280'); else { function('1024'); } Hello, How can we calculate size of image by using javascript ? Thanks in advance Hi All, I am using jFlow slider for my website and in the head there is that function <script type="text/javascript"> $(document).ready(function(){ $("#myController").jFlow({ slides: "#slides", controller: ".jFlowControl", // must be class, use . sign slideWrapper : "#jFlowSlide", // must be id, use # sign selectedWrapper: "jFlowSelected", // just pure text, no sign auto: true, //auto change slide, default true width: "706px", height: "420px", duration: 500, prev: ".jFlowPrev", // must be class, use . sign next: ".jFlowNext" // must be class, use . sign }); }); </script> What i want to do is detect the browser window (max width 1024 ) and change the width and height attribute of this function...something like this : <SCRIPT language="JavaScript"> <!-- if ((screen.width<=1024) && (screen.height<=768)) { $(document).ready(function(){ $("#myController").jFlow({ slides: "#slides", controller: ".jFlowControl", // must be class, use . sign slideWrapper : "#jFlowSlide", // must be id, use # sign selectedWrapper: "jFlowSelected", // just pure text, no sign auto: true, //auto change slide, default true width: "706px", height: "420px", duration: 500, prev: ".jFlowPrev", // must be class, use . sign next: ".jFlowNext" // must be class, use . sign }); }); } else { $(document).ready(function(){ $("#myController").jFlow({ slides: "#slides", controller: ".jFlowControl", // must be class, use . sign slideWrapper : "#jFlowSlide", // must be id, use # sign selectedWrapper: "jFlowSelected", // just pure text, no sign auto: true, //auto change slide, default true width: "706px", height: "420px", duration: 500, prev: ".jFlowPrev", // must be class, use . sign next: ".jFlowNext" // must be class, use . sign }); }); } //--> </SCRIPT> But can't get this to work...any help please?? //Sam I have a form that allows photos to be uploaded. I am using Perl to do this, and it works fine. Now I want to validate that the size of the image does not exceed a certain limit BEFORE it actually uploads. I can do that in Perl using something like the code below. But, I would rather do this in Javascript. I already have a routine that validates that the image file name does not contain embedded spaces. I would like to add this there. Can this be done in Javascript? Code: if ($ENV{'CONTENT_LENGTH'} > 100000) { print "SIZE EXCEEDS LIMIT!" } hello friends I'm a newbie.. I need a little help. Im using big images in my website. I want a javascript to toggle the image size from "Original size to fit with resolution of screen" and vice versa. It should be onclick function like this <img id="blahblah" src="myimage.jpg" onClick="resize();" /> Hello everyone! I'm using Cut & Paste Plus Size image viewer ( http://www.javascriptkit.com/script/...geviewer.shtml ) , but I noticed some problem. When the large image is loaded initially, it's not always positioned on the center of the page. After that the script works just fine, until the browser is re-started. There is link to my page: http://www.accentironwork.com/yard%20decorations.html Script code is the http://www.accentironwork.com/plusimageviewer.js http://www.accentironwork.com/plusimageviewer.css I hope some body can help me. Thanks in advance! Hello I was looking for a javascript code to show an image in full size on moueover, I use this script on the site Code: function ShowPicture(id,Source) { if (Source=="1"){ if (document.layers) document.layers[''+id+''].visibility = "show" else if (document.all) document.all[''+id+''].style.visibility = "visible" else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible" } else if (Source=="0"){ if (document.layers) document.layers[''+id+''].visibility = "hide" else if (document.all) document.all[''+id+''].style.visibility = "hidden" else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden" } } CSS code i use: Code: <style type="text/css"> #Style { position:absolute; visibility:hidden; border:solid 1px #CCC; padding:5px; } </style> On the site to to body I put this html code: Code: <a href="#" onMouseOver="ShowPicture('Style',1)" onMouseOut="ShowPicture('Style',0)">Click Here To Show Image</a> <div id="Style"><img src="/sites/default/files/peroulades.jpg"></div> When Im hovering over the link image is shown full size, Problem: if you take a look: http://www.online-dovolenka.sk/dovolenka_korfu if hover over both links "Click Here To Show Image" you will see same image, but I put two different images? where is the problem? any ideas? Code: <a href="#" onMouseOver="ShowPicture('Style',1)" onMouseOut="ShowPicture('Style',0)">Click Here To Show Image</a> <div id="Style"><img src="/sites/default/files/peroulades.jpg"></div> <a href="#" onMouseOver="ShowPicture('Style',1)" onMouseOut="ShowPicture('Style',0)">Click Here To Show Image</a> <div id="Style"><img src="/sites/default/files/pantokrator.jpg"></div> I have followed all the correct steps to the Javascriptkit code for Plus Size Image Viewer: http://www.javascriptkit.com/script/...eviewer.shtml# Everything works fine but the Enlarge Image buttons are not where they should be. They should all appear at the bottom left of each individual image and are floating up. See example he http://www.bannerpen.ca/plastic_glossy.html Im not sure if the problem is the position or the display or none in the plusimageviewer.css script?? [CODE] .enlargecaption{ position: absolute; border: 1px dotted navy; font: normal 11px Arial; } .enlargecaption a{ display:block; background: lightgray; /*bg color of caption*/ padding: 3px; text-decoration: none; color: black; } .enlargecaption a:hover{ background: lightyellow; /*bg color of caption when mouse rolls over it*/ } .enlargebox{ position: absolute; border:1px solid gray; display:none; } .enlargebox .title{ background:gray; color:white; padding: 3px 2px; text-align: right; font:bold 14px Arial; } .enlargebox .title img{ cursorointer; cursor:hand; } [CODE] Hi. Sort of new to Javascript. I am implementing a zoom in feature, but actually tricking the user as a full screen image is simply being stretched. I plan to apply it to several pages, and don't really fancy working out the pixels for each. I believe that if you simply put width: 150% height 150% it will change the image size relative to the browser. I don't want that, I want it relative to the original image size. Could I do sort of height*1.5 or something? How would I write that if so? Thanks! Code: <script> $('#in').click(function() { $('#drag img').animate({ width: '150%', height: '150%', }, 5000, function() { // Animation complete. }); }); </script> Hi, I'm new here and trying to get some basics via examples. On this page http://www.gilariverwoodworks.com/kitchens.htm I have thumbnails in a table. Immediately below the table is a full sized image of thumb 1. I want to mouseover the thumbs and have the respective full size images swap. The thumbs remain as is. All the thumbs are the same file as the full size image but resized. If moused over, the new image should remain until the next thumb is moused over - ie no autoclose or return to original image. The viewer should be able to move around the page without having the image change til the next mouseover All the images are the same size Can someone offer or direct me to a script that will do this? TIA mr johnson I'm still struggling for a solution here. I have a background image that auto-resizes based on browser window / screen resolution. I want my top header menu, which requires links, to act in the same way and be in roughly the same position/size based on browser window. Is this possible? In the sample below, the image is just part of the background image to give you an idea of the look I am trying to duplicate. Is there a Javascript out there that will help me or will I be stuck having to rework my design? http://www.uberbotjones.com/sanny/test.html This site is really driving me crazy. Hello all, Essentially what I am trying to get without much success on the issue is this: I want an icon in my template that, when you click on that certain icon (image), a drop down menu appears. You know when you click the file option in your browser's toolbar, and a drop down menu appears? It can be just like that, but instead of save as and open, links will be there to places within our intranet opened in a new window. This has to work for IEX 7+ because that's all our company decides to use. I tried to submit a chang erequest for them to move to a better CSS/Javascript supportive browser such as Opera, Firefox, Google Chrome... but they're way too fixed on IEX for some odd reason. I am obliged for any help on this. *edit* colors dont matter. It can be the default colors used in a basic drop down menu. I figure javascript would have more options though. |