I used this command: gs -q -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -r150 -dJPEGQ=75 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dUseTrimBox -dFirstPage=1 -dLastPage=5 -sOutputFile=/var/www/html/dev/konradb/preview_reference/preview_reference/sites/all/modules/hiflex/webshop/data/default/data/upload/print_files/logged/connected/preview/dd79f456b253a178affd21ced5eaf2c35e9fc827901a58671f3bd42801ae6d0d991082cc4ab44adb/%09d.jpg /var/www/html/dev/konradb/preview_reference/preview_reference/sites/all/modules/hiflex/webshop/data/default/data/upload/print_files/logged/connected/pdf/dd79f456b253a178affd21ced5eaf2c35e9fc827901a58671f3bd42801ae6d0d991082cc4ab44adb/file.pdf as you can see I have very long paths. Problem is with sOutputFile parameter if it's to long (as in my example) you will receive an error with information "location doesn't exist" or something similar. When I use short path everything is ok.
*** This bug has been marked as a duplicate of bug 693380 ***