Cross-browser window resize event – JavaScript / jQuery

jQuery has a built-in method for this: $(window).resize(function () { /* do something */ }); For the sake of UI responsiveness, you might consider using a setTimeout to call your code only after some number of milliseconds, as shown in the following example, inspired by this: function doSomething() { alert(“I’m done resizing for the moment”); … Read more

Image resizing client-side with JavaScript before upload to the server

Here’s a gist which does this: https://gist.github.com/dcollien/312bce1270a5f511bf4a (an es6 version, and a .js version which can be included in a script tag) You can use it as follows: <input type=”file” id=”select”> <img id=”preview”> <script> document.getElementById(‘select’).onchange = function(evt) { ImageTools.resize(this.files[0], { width: 320, // maximum width height: 240 // maximum height }, function(blob, didItResize) { // … Read more

How to easily resize/optimize an image size with iOS?

A couple of suggestions are provided as answers to this question. I had suggested the technique described in this post, with the relevant code: + (UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize; { UIGraphicsBeginImageContext( newSize ); [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)]; UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; } As far as storage of the image, the fastest image format to use with … Read more

Something seems wrong with the layout, JButton showing unexpected behaviour at resize of the window

The problem with your very nice example may be platform dependent, but I can offer a few observations: You’re not adding or removing components, so you don’t need revalidate(). Because the background color is a bound property of the buttons, you don’t need the subsequent calls to repaint(). You do need repaint() in your custom … Read more

How to resize an Image C#

This will perform a high quality resize: /// <summary> /// Resize the image to the specified width and height. /// </summary> /// <param name=”image”>The image to resize.</param> /// <param name=”width”>The width to resize to.</param> /// <param name=”height”>The height to resize to.</param> /// <returns>The resized image.</returns> public static Bitmap ResizeImage(Image image, int width, int height) { … Read more