class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
It is currently not possible to avoid calculation if the uploaded image has already the dimensions that you want to resize it to.
However, the class provides some information about the image, before calling process(). Available are image_src_x, image_src_y and the newly introduced image_src_bits, image_src_pixels and image_src_type. Using these, you can process the picture differently.
For your second question, if you use $handle->image_convert = ' jpg ';, then all images will be converted to JPEG. If you want to restrict to JPEG only, use:
However, the class provides some information about the image, before calling process(). Available are image_src_x, image_src_y and the newly introduced image_src_bits, image_src_pixels and image_src_type. Using these, you can process the picture differently.
For your second question, if you use $handle->image_convert = ' jpg ';, then all images will be converted to JPEG.
If you want to restrict to JPEG only, use: