ID:2396567
 
Code:
mob/verb/test()

src << "Image existence test"
src << fexists("photo/2018/test/example.jpg") // Returns 1
src << length(file("photo/2018/test/example.jpg")) // Returns correct size
src << browse(file("photo/2018/test/example.jpg")) // Displays .jpg in browser

src << "Image resizing test"
var/icon/picture = icon(file("photo/2018/test/example.jpg")) // Issue: returns a blank icon in Linux - works in Windows
var/height = picture.Height() // returns 0 in Linux
var/width = picture.Width() // returns 0 in Linux

if(height && width)
var/percent = height > width ? 600/height : 800/width
var/imagewidth = round(width * percent)
var/imageheight = round(height * percent)

picture.Scale(imagewidth, imageheight)
fcopy(picture,"photo/2018/test/example.png")

else
src << "Image resize test failed"


Problem description:

Alright, so the code above is intended to take a .jpg file stored on the server, convert that file to an icon, resize the icon, then spit out the finished .png file back to the server in the same location. It works great in Windows, however the issue occurs when I move to Linux, the .jpg file fails to convert into an icon (no runtime error), producing an empty icon with 0 height and 0 width. The resize fails from there forward.

My first thoughts were that pathing syntax was the culprit, but fexists() returns ok, length() returns the correct size, and browse() displays the image in the browser. I’ve tried different syntaxs for creating an icon (using new() instead of icon(), dropping the file(), prefixing a ./ to the filepath) with the same failed results.

Anyone have suggestions or ideas? I’m open to trying a resize that doesn’t involve icons.
It appears that the .jpg image is created into an icon, but the Width() and Height() always return 0 (other icon procs seem to work fine). This appears to be a bug, and a bug report has been opened.

For anyone else who may have run into this same issue, the following snippet will calculate the width/height until the bug is resolved:

proc
jpgwidth(var/icon/I)
if(istype(I))
while(I.GetPixel(.+1,1) != null)
.++

jpgheight(var/icon/I)
if(istype(I))
while(I.GetPixel(1,.+1) != null)
.++