HTML - Resizing Images (canvas Resize)
Alright, well I'm needing to resize an image. Not a scaled version, but a 'cropped' version. Like it's called canvas resize in photoshop ect. I hope someone knows what I'm talking about lol
Similar TutorialsOK, what I want to do is set an image in a cell which will change size as the browser window is resized. So, say I have a three-cell table: ------------------------------------------------ | ---------------------------------------------- | | ---------------------------------------------- | |----------------------------------------------| | ,,,,,,,,,,,,,,, | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, | | ,,,,,,,,,,,,,,, | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, | | ,,,,,,,,,,,,,,, | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, | | ,,,,,,,,,,,,,,, | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, | | ,,,,,,,,,,,,,,, | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, | | ,,,,,,,,,,,,,,, | ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, | ------------------------------------------------ It is set to width=100% and height=100% (using css). The top cell has a fixed height of 50, the bottom-right cell has a fixed width of 600 (all this is just hypothetical, the actual page will be much more complicated). So, the bottom-left cell will be changing in height and width as the browser window is resized. The problem is that when I put an image in the cell and say height="100%" and width="100%" the thing doesn't work. If I give the cell and image a set width or height, the other dimension (height or width) stretches just fine. I know that the problem is that the image wants to maintain a certain aspect ratio (say, 1:3). What I want to know, in short, is if there is any way to override this and make the image render to the size of the cell whether or not that maintains the proper aspect ratio. Hi. I was wondering if there is an html code or a way for me to reduce the size of images on a page by percentages. The reason being, we have images that are 200x200 and then some 200x150, etc. at random sizes. When I use the "image size =" in html, the images are coming out distorted. I would just like to reduce the images by 50% on width and length. Any ideas would be greatly appreciated. Daniel So I know if you use "%" to define your height and width with tables that it allows you the table to resize based upon a users browser size. My question is how can you do this with images? I tried setting my height and width for my image using "%" but then my image just becomes overly stretched. My professor said that I should create a table and than place the image within the table, and then set the table height and width using "%". The code below is what I tried. It didn't work though. Any ideas on how to do this? Code: <body> <table width="100%" height="100%" border="0"> <tr> <td height="100%" width="100%"><p align="center"><img src="images/Banner.png" align="center" class="source-image" /></p></td> </tr> </table> </body> Thank you for your help! i have to draw ball on canvas in html 5 depending on the input given by user in a textbox. ex: if a user enter 5 in a textfield, 5 ball should draw on canvas. My excuses for bothering you with this but I need a little push in the right direction to get started. I'm a 3d (technical) artist, but my HTML knowledge is minimal. What I have is: - A PNG image without alpha to be used as the background. - One or more PNG's with alpha to be composited on top of this background using the embedded alpha channels. I want to do this using the Canvas element and what I learned from searching the web is they often composite everything offscreen and then draw it to the Canvas. So if anyone could provide me with small example I would be eternally grateful. It's mainly the syntax that stumps me right now. Thanks in advance. Hey guys, I'm having trouble typing in Canvas. I tried combining the jquery keyboard (http://net.tutsplus.com/tutorials/ja...ss-and-jquery/) with the canvas in order to directly type on the canvas, but I'm having trouble doing so. Does anyone have any suggestions? I really appreciate any help you can give me! Below is pasted the code I have tried so far... <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Online Keyboard</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <style> body { margin: 0px; padding: 0px; } #myCanvas { border: 1px solid #9C9898; } </style> <script> window.onload = function(){ var canvas = document.getElementById("myCanvas"); var context = canvas.getContext("2d"); var x = 50; var y = 50; context.font = "12pt Calibri"; //context.fillStyle = "orange"; // text color context.fillText($(function(){ var $write = $('#write'), shift = false, capslock = false; $('#keyboard li').click(function(){ var $this = $(this), character = $this.html(); // If it's a lowercase letter, nothing happens to this variable // Shift keys if ($this.hasClass('left-shift') || $this.hasClass('right-shift')) { $('.letter').toggleClass('uppercase'); $('.symbol span').toggle(); shift = (shift === true) ? false : true; capslock = false; return false; } // Caps lock if ($this.hasClass('capslock')) { $('.letter').toggleClass('uppercase'); capslock = true; return false; } // Delete if ($this.hasClass('delete')) { var html = $write.html(); $write.html(html.substr(0, html.length - 1)); return false; } // Special characters if ($this.hasClass('symbol')) character = $('span:visible', $this).html(); if ($this.hasClass('space')) character = ' '; if ($this.hasClass('tab')) character = "\t"; if ($this.hasClass('return')) character = "\n"; // Uppercase letter if ($this.hasClass('uppercase')) character = character.toUpperCase(); // Remove shift once a key is clicked. if (shift === true) { $('.symbol span').toggle(); if (capslock === false) $('.letter').toggleClass('uppercase'); shift = false; } // Add the character $write.html($write.html() + character); }); }); , x, y); }; </script> </head> <body> <body onmousedown="return false;"> <canvas id="myCanvas" width="578" height="200"> </canvas> <div id="container"> <textarea id="write" rows="6" cols="60"></textarea> <ul id="keyboard"> <li class="symbol"><span class="off">`</span><span class="on">~</span></li> <li class="symbol"><span class="off">1</span><span class="on">!</span></li> <li class="symbol"><span class="off">2</span><span class="on">@</span></li> <li class="symbol"><span class="off">3</span><span class="on">#</span></li> <li class="symbol"><span class="off">4</span><span class="on">$</span></li> <li class="symbol"><span class="off">5</span><span class="on">%</span></li> <li class="symbol"><span class="off">6</span><span class="on">^</span></li> <li class="symbol"><span class="off">7</span><span class="on">&</span></li> <li class="symbol"><span class="off">8</span><span class="on">*</span></li> <li class="symbol"><span class="off">9</span><span class="on">(</span></li> <li class="symbol"><span class="off">0</span><span class="on">)</span></li> <li class="symbol"><span class="off">-</span><span class="on">_</span></li> <li class="symbol"><span class="off">=</span><span class="on">+</span></li> <li class="delete lastitem">delete</li> <li class="tab">tab</li> <li class="letter">q</li> <li class="letter">w</li> <li class="letter">e</li> <li class="letter">r</li> <li class="letter">t</li> <li class="letter">y</li> <li class="letter">u</li> <li class="letter">i</li> <li class="letter">o</li> <li class="letter">p</li> <li class="symbol"><span class="off">[</span><span class="on">{</span></li> <li class="symbol"><span class="off">]</span><span class="on">}</span></li> <li class="symbol lastitem"><span class="off">\</span><span class="on">|</span></li> <li class="capslock">caps lock</li> <li class="letter">a</li> <li class="letter">s</li> <li class="letter">d</li> <li class="letter">f</li> <li class="letter">g</li> <li class="letter">h</li> <li class="letter">j</li> <li class="letter">k</li> <li class="letter">l</li> <li class="symbol"><span class="off">;</span><span class="on">:</span></li> <li class="symbol"><span class="off">'</span><span class="on">"</span></li> <li class="return lastitem">return</li> <li class="left-shift">shift</li> <li class="letter">z</li> <li class="letter">x</li> <li class="letter">c</li> <li class="letter">v</li> <li class="letter">b</li> <li class="letter">n</li> <li class="letter">m</li> <li class="symbol"><span class="off">,</span><span class="on"><</span></li> <li class="symbol"><span class="off">.</span><span class="on">></span></li> <li class="symbol"><span class="off">/</span><span class="on">?</span></li> <li class="right-shift lastitem">shift</li> <li class="space lastitem"> </li> </ul> </div> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="js/keyboard.js"></script> </body> </html> I'm drawing text on the screen (mouse coordinates) in this example: http://www.hindbrain.net/ex5.php In order to not have new text overlay old text and become unreadable, I have to clear a background rectangle and then draw the new text. Is there a way to clear the background rectangle so that it is not white or any solid color? Ie, is there a way to just clear it so that the original blue background is still there? thanks, William Is this possible? I'd like to draw a screen using the canvas methods and then overlay html hyperlinks on this (fullscreen) canvas. I have experimented with capturing the mouse click event and know where I clicked on the canvas, but now I'd just like to be able to hyperlink to places right from the canvas. It would be convenient if you could somehow embed hrefs there. thanks, William Hello all, I am trying to replicate a style I have seen on the site listed below, where they appear to be using the CANVAS command to create a gradient top and bottom margin. I can seem to find anything online about how to do this but obviously they have figured it out. http://www.xtrememac.com/ Any ideas or pointing me in the right direction are greatly appreciated. Thanks! I'm an intermediate PS user/css coder/etc but I haven't had to design many sites from the ground up. With that said, I now have to design a web site that will work for the 800x600 crowd. What canvas size do I use in Photoshop to work with? Also, what would be the canvas size to use designing for 1024x768 screen resolutions? Thanks. Hello, hopefully i can find help here I want to save my canvas-content to a single image-file. There are an approach using todataurl(), which works fine. But not if i draw an image-file (e.g. car.jpg or house.png) to the canvas additionally. It does not return the whole image? Here I have my simple example-code: <head> <script> window.onload = function() { var canvas = document.getElementById("theCanvas"); var context = canvas.getContext("2d"); context.fillStyle = "navy"; context.fillRect(0,0,20,20); var imagefile = new Image(); imagefile.onload = function () { context.drawImage(imagefile, 22, 0,60,60); } imagefile.src = "http://www.sign-arts.de/joomla/images/stories/print_proj/mediclin/icon1.gif"; window.open(canvas.toDataURL('image/png')); }; </script> </head> <body id="bodi"> <canvas id="theCanvas" width="500" height="200" > </canvas> </body> Only the HTML5-methods like fillRect() are rendered to the new window, why this is so? What im doing wrong? Thanx in advance for help bilinok I need to go to the experts here , what I need to do is the following. I have an Adobe Edge animation, I need to take that animation along with a JQuery dropdown menu and put both on one html page. I have basic html knowledge to the point where the edge animation is saved as an html page ( edge automatically does this which includes all the Javascript files separately) So far I'm able to take the edge <div> and ad it to any html page as long as I copy the scripts to the head of that page. The trouble I'm having is adding the JQuery dropdown. It would be impossible for anyone reading this to know EXACTLY wht I mean without seeing the code, I do not want to add abunch of it or add a link to the files until someone replies and can actually look. any help? RD I have found what seems to be a rather big problem in the HTML canvas When drawing circles, and I presume all shapes, the size of the circle is different based on whether one is filling it, or sketching it. If we have a circle of radius 10 and line width k, and we decide to fill it, that line width will be evenly dispersed about the perimeter of the circle such that half the line width is inside the circle, and half is outside the circle. If, however, the same circle is sketched, the line width will still be the same, but it will now be dispersed entirely on the outside of the circle, thus making it larger. If I am wrong, and this is how figures are supposed to be drawn, or if I am simply not using the right settings, please let me know =) Hello, I'm kinda new to HTML, but have used it for a long time, just haven't used it to do stuff from scratch before. I was wondering how I would set up a page to resize and not have scrollbars. I'll attach an example. I want there to be a footer that will ALWAYS be at the bottom of the window, not just the content. I wan to have a middle section that will stretch between my header and footer, and I want it to have somewhat of an internal scrollbar if the content inside is bigger than the window: Code: The header footer, and middle section should fill the browser window ----------------------------------------------- header ----------------------------------------------- xxxxxxxxxxxxxxxxxx[^] -------------- xxxxxxxxxxxxxxxxxx| | | content: height=100%| | | | xxxxxxxxxxxxxxxxxx| | | | xxxxxxxxxxxxxxxxxx| | | more | xxxxxxxxxxxxxxxxxx| | | here | xxxxxxxxxxxxxxxxxx[v] _________| ------------------------------------------------ footer(bottom aligned to browser window ------------------------------------------------ Ok the ASCII isn't working too well... EDIT: Ok I got the footer working, but what about making the middle part span the width from the bottom of the header to the top of the footer without stretching out the page? Is there a way to disable the resizing of a window in firefox? I'm using this code: window.open('google.com','newwin','width=200,height=200,resizable=no') In Internet Explorer it's working fine but in Firefox it's not Thanks Hi, is there a way that a window opens with a specific size? (not the window that opens with a link on a page) for example, when i go into www.gucci.com-the window will automatically resize to their specific size. I want my own website to open in a specific size but im not sure how.. Hi there, I have some text inside a layer and I am pretty happy with it. Trouble is that I would like to disable the resizing from the browser so that the user cannot choose a text size that would mess up my text. I am refering to "View > Text Size" in IE. Can u help? Thks I'm using the example frame as laid out he http://www.quackit.com/html/template...example_6.html and I'm struggling to figure out how to resize the 'Related' frame. I want to make it stretch to the top and bottom of the page (therefore making the width of the top and bottom rows smaller). The frame set code is: <frameset rows="100,*,80" frameborder="0" border="0" framespacing="0"> <frame name="topNav" src="top_nav.html"> <frameset cols="200,*,200" frameborder="0" border="0" framespacing="0"> <frame name="menu" src="menu_1.html" marginheight="0" marginwidth="0" scrolling="auto" noresize> <frame name="content" src="content.html" marginheight="0" marginwidth="0" scrolling="auto" noresize> <frame name="related" src="related.html" marginheight="0" marginwidth="0" scrolling="auto" noresize> </frameset> <frame name="footer" src="footer.html"> </frameset> </html> and the codes for the frames can be found he http://www.quackit.com/html/examples...ple_6_code.cfm To give you an idea of what I'm trying to achieve, I want to make the right hand lion extend up and down so that when the page resizes, the colours for the top and bottom borders will always match seamlessly. At the minute I have only managed to make the horizontal JPG smaller, not the actual frame. I have a site which uses frames. I recently added a new page and in the page there is a link to open up a jukebox ,I made, in the upper frame. The frame the link is in is below the one where it is suppose to open. Everything works fine but the size for the top frame is smaller than the jukebox I want in there. So when you open up the link it opens the jukebox up but only a portion is shown. I have it so you are allowed to scroll but I'd prefer that the frame would be automatically rezized to fit the jukebox. Is that possible? If so can you please let me know how? Any Help is Appreciated hi.i need some help : i got a web page that looks something like this how can i make the background image to autoresize according to the screen resolution of the monitor from where the page is seen?same with the banner and the rest of the images.i basically want my website to look exactly like in the picture no matter what is the resolution of the screen and without a scroll bar. and another thing: how can i make to load only the text on the orangebox when i click a side link(e.g:assus) without refreshing the hole page.and how can i put a scroll only on the orange box so i can put a longer text and not to exit from that rectangular space? thank you |