eval is evil ( not always ). But in your example i would try to avoid it.
In your code you could use call_user_func instead:
$source = call_user_func( 'imagecreatefrom' . $type, $image );
As if on this question explained:
- Sometimes eval is the only/the right solution.
- For most cases one should try something else.
- If unsure, goto 2.
- Else, be very, very careful.