Dayzza
Dayzza

Reputation: 1557

how do i convert PNG to JPG in PHP?

I want read a google map url, convert the map to jpg & return the jpg map.

I suppose to have two markers in my map. however each time the map return to me only contains the first marker. Is there some characters that cannot be used thats why my url is cut short?

i.e.

<?php
$url = "http://maps.google.com/maps/api/staticmap?center=1.2993485,103.7875769&zoom=14&size=558x908&sensor=false&markers=color:blue|size:small|1.2993485,103.7875769&markers=color:blue|size:small|1.3050607723691974, 103.78171026706696";

$img = ImageCreateFromPng($url);

if($img) {
  header("Content-Type: image/jpeg");
  Imagejpeg($img);
  ImageDestroy($img);
} 
?>

Upvotes: 1

Views: 835

Answers (1)

GWW
GWW

Reputation: 44093

I am guessing that the space between 1.3050607723691974, 103.78171026706696 is not being properly escaped (and that it's probably a mistake).

When you cut and paste the URL in your browser the space is probably being escaped with %20, which "corrects" the error.

Upvotes: 1

Related Questions