Skip to main content
added 1 character in body
Source Link
KIKO Software
  • 5.9k
  • 13
  • 23

This is going to be a reasonably short review, with just a few ideaideas I had when I looked at your code. Other people might do a thorough review.

die, die, die

You used this a lot: die('{"error":"The error message."}');, you could create a function for that:

function returnError($message)
{
   die(json_encode(["error" => $message]));
}

Notice that I actually use json_encode() to create the JSON string. This is better because certain characters should be escaped inside a JSON string value. If you also want to log these errors you can do that in this function.

Image Processing and Generation

You are using GD for your image functions, and you're restricting the image formats to 'jpg', 'jpeg', 'png' and the size to between 100 and 2000 for width and height.

Although I can understand why you made these choices, I think your users will be happier if you were just simply able to accept the images they upload. Perhaps they have a TIFF image, or something from a mobile phone which can easily be bigger than 2000 pixels.

It's probably not because your server cannot handle these images, it's just that GD cannot. PHP however supports other image processing extensions like Gmagick and ImageMagick.

These are very similar to each other and far more powerful than GD. They support over a 100 image formats. Rewriting your code for one of these extensions means the images your users upload will be more readily accepted and that can only be a good thing.

All you do is try to load the image in one of these extension and see if it worked. If it did you resize and save it, and you're done. If it didn't work you return a detailed error message.

This is going to be a reasonably short review, with just a few idea I had when I looked at your code. Other people might do a thorough review.

die, die, die

You used this a lot: die('{"error":"The error message."}');, you could create a function for that:

function returnError($message)
{
   die(json_encode(["error" => $message]));
}

Notice that I actually use json_encode() to create the JSON string. This is better because certain characters should be escaped inside a JSON string value. If you also want to log these errors you can do that in this function.

Image Processing and Generation

You are using GD for your image functions, and you're restricting the image formats to 'jpg', 'jpeg', 'png' and the size to between 100 and 2000 for width and height.

Although I can understand why you made these choices, I think your users will be happier if you were just simply able to accept the images they upload. Perhaps they have a TIFF image, or something from a mobile phone which can easily be bigger than 2000 pixels.

It's probably not because your server cannot handle these images, it's just that GD cannot. PHP however supports other image processing extensions like Gmagick and ImageMagick.

These are very similar to each other and far more powerful than GD. They support over a 100 image formats. Rewriting your code for one of these extensions means the images your users upload will be more readily accepted and that can only be a good thing.

All you do is try to load the image in one of these extension and see if it worked. If it did you resize and save it, and you're done. If it didn't work you return a detailed error message.

This is going to be a reasonably short review, with just a few ideas I had when I looked at your code. Other people might do a thorough review.

die, die, die

You used this a lot: die('{"error":"The error message."}');, you could create a function for that:

function returnError($message)
{
   die(json_encode(["error" => $message]));
}

Notice that I actually use json_encode() to create the JSON string. This is better because certain characters should be escaped inside a JSON string value. If you also want to log these errors you can do that in this function.

Image Processing and Generation

You are using GD for your image functions, and you're restricting the image formats to 'jpg', 'jpeg', 'png' and the size to between 100 and 2000 for width and height.

Although I can understand why you made these choices, I think your users will be happier if you were just simply able to accept the images they upload. Perhaps they have a TIFF image, or something from a mobile phone which can easily be bigger than 2000 pixels.

It's probably not because your server cannot handle these images, it's just that GD cannot. PHP however supports other image processing extensions like Gmagick and ImageMagick.

These are very similar to each other and far more powerful than GD. They support over a 100 image formats. Rewriting your code for one of these extensions means the images your users upload will be more readily accepted and that can only be a good thing.

All you do is try to load the image in one of these extension and see if it worked. If it did you resize and save it, and you're done. If it didn't work you return a detailed error message.

added 1 character in body
Source Link
KIKO Software
  • 5.9k
  • 13
  • 23

This is going to be a reasonably short review, with just a few idea I had when I looked at your code. Other people might do a thorough review.

die, die, die

You used this a lot: die('{"error":"The error message."}');, you could create a function for that:

function returnError($message)
{
   die(json_encode(["error" => $message]));
}

Notice that I actually use json_encode() to create the JSON string. This is better because certain characters should be escaped inside a JSON string value. If you also want to log these errors you can do that in this function.

Image Processing and Generation

You are using GD for your image functions, and you're restricting the image formats to 'jpg', 'jpeg', 'png' and the size to between 100 and 2000 for width and height.

Although I can understand why you made these choicechoices, I think your users will be happier if you were just simply able to accept the images they upload. Perhaps they have a TIFF image, or something from a mobile phone which can easily be bigger than 2000 pixels.

It's probably not because your server cannot handle these images, it's just that GD cannot. PHP however supports other image processing extensions like Gmagick and ImageMagick. 

These are very similar to each other and far more powerful than GD. They support over a 100 image formats. Rewriting your code for one of these extensions means the images your users upload will be more readily accepted and that can only be a good thing.

All you do is try to load the image in one of these extension and see if it worked. If it did you resize and save it, and you're done. If it didn't work you return a detailed error message.

This is going to be a reasonably short review, with just a few idea I had when I looked at your code. Other people might do a thorough review.

die, die, die

You used this a lot: die('{"error":"The error message."}');, you could create a function for that:

function returnError($message)
{
   die(json_encode(["error" => $message]));
}

Notice that I actually use json_encode() to create the JSON string. This is better because certain characters should be escaped inside a JSON string value. If you also want to log these errors you can do that in this function.

Image Processing and Generation

You are using GD for your image functions, and you're restricting the image formats to 'jpg', 'jpeg', 'png' and the size to between 100 and 2000 for width and height.

Although I can understand why you made these choice, I think your users will be happier if you were just simply able to accept the images they upload. Perhaps they have a TIFF image, or something from a mobile phone which can easily be bigger than 2000 pixels.

It's probably not because your server cannot handle these images, it's just that GD cannot. PHP however supports other image processing extensions like Gmagick and ImageMagick. These are very similar to each other and far more powerful than GD. They support over a 100 image formats. Rewriting your code for one of these extensions means the images your users upload will be more readily accepted and that can only be a good thing.

This is going to be a reasonably short review, with just a few idea I had when I looked at your code. Other people might do a thorough review.

die, die, die

You used this a lot: die('{"error":"The error message."}');, you could create a function for that:

function returnError($message)
{
   die(json_encode(["error" => $message]));
}

Notice that I actually use json_encode() to create the JSON string. This is better because certain characters should be escaped inside a JSON string value. If you also want to log these errors you can do that in this function.

Image Processing and Generation

You are using GD for your image functions, and you're restricting the image formats to 'jpg', 'jpeg', 'png' and the size to between 100 and 2000 for width and height.

Although I can understand why you made these choices, I think your users will be happier if you were just simply able to accept the images they upload. Perhaps they have a TIFF image, or something from a mobile phone which can easily be bigger than 2000 pixels.

It's probably not because your server cannot handle these images, it's just that GD cannot. PHP however supports other image processing extensions like Gmagick and ImageMagick. 

These are very similar to each other and far more powerful than GD. They support over a 100 image formats. Rewriting your code for one of these extensions means the images your users upload will be more readily accepted and that can only be a good thing.

All you do is try to load the image in one of these extension and see if it worked. If it did you resize and save it, and you're done. If it didn't work you return a detailed error message.

Source Link
KIKO Software
  • 5.9k
  • 13
  • 23

This is going to be a reasonably short review, with just a few idea I had when I looked at your code. Other people might do a thorough review.

die, die, die

You used this a lot: die('{"error":"The error message."}');, you could create a function for that:

function returnError($message)
{
   die(json_encode(["error" => $message]));
}

Notice that I actually use json_encode() to create the JSON string. This is better because certain characters should be escaped inside a JSON string value. If you also want to log these errors you can do that in this function.

Image Processing and Generation

You are using GD for your image functions, and you're restricting the image formats to 'jpg', 'jpeg', 'png' and the size to between 100 and 2000 for width and height.

Although I can understand why you made these choice, I think your users will be happier if you were just simply able to accept the images they upload. Perhaps they have a TIFF image, or something from a mobile phone which can easily be bigger than 2000 pixels.

It's probably not because your server cannot handle these images, it's just that GD cannot. PHP however supports other image processing extensions like Gmagick and ImageMagick. These are very similar to each other and far more powerful than GD. They support over a 100 image formats. Rewriting your code for one of these extensions means the images your users upload will be more readily accepted and that can only be a good thing.