Resize Google Maps marker icon image

If the original size is 100 x 100 and you want to scale it to 50 x 50, use scaledSize instead of Size. const icon = { url: “../res/sit_marron.png”, // url scaledSize: new google.maps.Size(50, 50), // scaled size origin: new google.maps.Point(0,0), // origin anchor: new google.maps.Point(0, 0) // anchor }; const marker = new google.maps.Marker({ … Read more

Resize images in PHP without using third-party libraries?

Finally, I’ve discovered a way that fit my needs. The following snippet will resize an image to the specified width, automatically calculating the height in order to keep the proportion. $image = $_FILES[“image”][“tmp_name”]; $resizedDestination = $uploadDirectory.md5($randomNumber.$filename).”_RESIZED.jpg”; copy($_FILES, $resizedDestination); $imageSize = getImageSize($image); $imageWidth = $imageSize[0]; $imageHeight = $imageSize[1]; $DESIRED_WIDTH = 100; $proportionalHeight = round(($DESIRED_WIDTH * $imageHeight) … Read more

Responsive css background images

If you want the same image to scale based on the size of the browser window: background-image:url(‘../images/bg.png’); background-repeat:no-repeat; background-size:contain; background-position:center; Do not set width, height, or margins. EDIT: The previous line about not setting width, height or margin refers to OP’s original question about scaling with the window size. In other use cases, you may … Read more

Resize image in PHP

You need to use either PHP’s ImageMagick or GD functions to work with images. With GD, for example, it’s as simple as… function resize_image($file, $w, $h, $crop=FALSE) { list($width, $height) = getimagesize($file); $r = $width / $height; if ($crop) { if ($width > $height) { $width = ceil($width-($width*abs($r-$w/$h))); } else { $height = ceil($height-($height*abs($r-$w/$h))); } … Read more