# Help with script - arithmetic jpeg error

**URL:** https://forum.kirupa.com/t/help-with-script-arithmetic-jpeg-error/289435
**Category:** Uncategorized
**Created:** [May 30, 2009, 8:45am UTC](https://forum.kirupa.com/t/help-with-script-arithmetic-jpeg-error/289435 "2009-05-30T08:45:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Mr\_Kikkoman](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@Mr\_Kikkoman](https://forum.kirupa.com/u/Mr_Kikkoman)
#### Post date: [May 30, 2009, 8:45am UTC](https://forum.kirupa.com/t/help-with-script-arithmetic-jpeg-error/289435/1 "2009-05-30T08:45:34Z")

</div>

```auto

<?php

if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {

    $im = imagecreatefromstring ($GLOBALS["HTTP_RAW_POST_DATA"]);
    
    //header("Pragma: no-cache"); 
    header('Content-Type: image/jpeg');
    header("Content-Disposition: attachment; filename=".$_GET['name'].".jpg");
    $created = imagepng($im);
    imagedestroy($im);
    $image = imagecreatefrompng($created);
    imagedestroy($created); 
    imagejpeg($image, '', 100);
    
} else echo 'An error occured.';

?>

```

this is the code im using. Converting a png to jpeg is the only workaround to what I’m doing atm which does the job. But, when I try opening the jpeg in Photoshop or any photo editing program it throws an error. It will open up in Preview and browsers though.

Any ideas what’s wrong there?

Thanks
