Asynchronously load images with jQuery

No need for ajax. You can create a new image element, set its source attribute and place it somewhere in the document once it has finished loading: var img = $(“<img />”).attr(‘src’, ‘http://somedomain.com/image.jpg’) .on(‘load’, function() { if (!this.complete || typeof this.naturalWidth == “undefined” || this.naturalWidth == 0) { alert(‘broken image!’); } else { $(“#something”).append(img); } … Read more

Using JavaScript to display a Blob

You can also get BLOB object directly from XMLHttpRequest. Setting responseType to blob makes the trick. Here is my code: var xhr = new XMLHttpRequest(); xhr.open(“GET”, “http://localhost/image.jpg”); xhr.responseType = “blob”; xhr.onload = response; xhr.send(); And the response function looks like this: function response(e) { var urlCreator = window.URL || window.webkitURL; var imageUrl = urlCreator.createObjectURL(this.response); document.querySelector(“#image”).src … Read more

img tag displays wrong orientation

I found part of the solution. Images now have metadata that specify the orientation of the photo. There is a new CSS spec for image-orientation. Just add this to your CSS: img { image-orientation: from-image; } According to the spec as of Jan 25 2016, Firefox and iOS Safari (behind a prefix) are the only … Read more

Remove alpha channel in an image

The accepted answer to export to JPG, then back to PNG is not recommended. It’s an extra step in the process (2 exports) JPG is lossy, so you will lose some image data Here’s a super fast and easy way to do this without the extra export or saving to (lossy) JPG: Using Preview app … Read more

Fast way to get image dimensions (not filesize)

The file command prints the dimensions for several image formats (e.g. PNG, GIF, JPEG; recent versions also PPM, WEBP), and does only read the header. The identify command (from ImageMagick) prints lots of image information for a wide variety of images. It seems to restrain itself to reading the header portion (see comments). It also … Read more

embedding image in html email

Try to insert it directly, this way you can insert multiple images at various locations in the email. <img src=”data:image/jpg;base64,{{base64-data-string here}}” /> And to make this post usefully for others to: If you don’t have a base64-data string, create one easily at: http://www.motobit.com/util/base64-decoder-encoder.asp from a image file. Email source code looks something like this, but … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)