I think it would be better to send the filename to your function, instead of $mysock[0] and $mysock[1].

Something like this (I haven't tested it, so it might as well explode ...):

function imageResize($image, $target) {
list($width, $height) = getimagesize($image);

[...]

}

And then call the function like this:

<img src="images/sock001.jpg" <?php echo imageResize("images/sock001.jpg", 150); ?>>