14

I want to develop a web portal that will show the images dynamically produced by QGIS, but QGIS provided tiff images are too big in size and it is not possible to show it on website using image viewers. That's why I have decided to convert those tiff images into jpg/jpeg to reduce in size as well as browser friendly so that I can show those images on my website easily. But I don't know how to convert tiff images into jpg/jpeg using gdal commands.

Please help me in this regard.

  • two questions: 1) do you want only to change(convert) the image type from tiff to jpg or do you also want to resize? 2)which operating system do you use? – Kurt May 26 '12 at 15:22
  • I also want to resize and I'm using ubuntu – Enamul Haque May 26 '12 at 17:13
  • If you have a WMS then the choice of format is determined by the the client, so a web client can request jpeg or png and a desktop GIS can select TIFF, and no need to convert yourself – nmtoken Dec 10 '17 at 18:42
27

try this with gdal:

gdal_translate -of JPEG -scale -co worldfile=yes input.tiff output.jpg

it also create worldfile too...

i hope it helps you...

  • thanks to those who commented on my post. Aragon your solution worked for me – Enamul Haque May 26 '12 at 17:22
  • one more thing how can I do it dynamically so that I can show the image on the website – Enamul Haque May 26 '12 at 17:42
  • If you keep getting solid black output, you might need to specify the min and max values for scale. I used gdalinfo to get the min and max, then provide them like ... -scale 0 0.158 ... – Tom Saleeba Jan 31 '18 at 3:03
  • Good, but it discards any color information from the band rendering. Do you know how to keep it? – Rodrigo Nov 7 at 13:41
12

Hei!

Choose Raster menu - Conversion - Translate (Convert format). Then choose *Input file* for the image You want to convert. Under the *Output file* You can choose the format You need. There is .jpg too (with some 20+ file types).

I got 40MB large .tiff file, after conversion its only 1,6 MB as .jpg.

  • 1
    Good, but it discards any color information from the band rendering. Do you know how to keep it? – Rodrigo Nov 7 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.