Post by leeburgess » Wed Jul 31, 2019 10:22 pm

I have over 5000 images is there a tool I can use to find any corrupt images?

New member

Posts

Joined
Sat Sep 16, 2017 3:19 am

Post by wrick0 » Wed Jul 31, 2019 10:27 pm

try bad peggy

you can download it here

https://www.coderslagoon.com/

Active Member

Posts

Joined
Fri Jan 18, 2019 10:00 pm
Location - 127.0.0.1 @ The Netherlands

Post by leeburgess » Thu Aug 01, 2019 4:03 pm

Is there any other way using PHP?

New member

Posts

Joined
Sat Sep 16, 2017 3:19 am

Post by letxobnav » Thu Aug 01, 2019 5:45 pm

if(!imagecreatefromjpeg($file_path)) error_log('image '.$file_path.' seems pretty bad');
if(!getimagesize($file_path)) error_log('yep, image '.$file_path.' looks corrupt');

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by leeburgess » Thu Aug 01, 2019 8:18 pm

And where do I put that please?

New member

Posts

Joined
Sat Sep 16, 2017 3:19 am

Post by letxobnav » Thu Aug 01, 2019 8:36 pm

Basically, OC already uses those functions.
in system/library/image.php you have:

Code: Select all

		if (file_exists($file)) {
			$this->file = $file;

			$info = getimagesize($file);

			$this->width  = $info[0];
			$this->height = $info[1];
			$this->bits = isset($info['bits']) ? $info['bits'] : '';
			$this->mime = isset($info['mime']) ? $info['mime'] : '';

			if ($this->mime == 'image/gif') {
				$this->image = imagecreatefromgif($file);
			} elseif ($this->mime == 'image/png') {
				$this->image = imagecreatefrompng($file);
			} elseif ($this->mime == 'image/jpeg') {
				$this->image = imagecreatefromjpeg($file);
			}
		} else {
			exit('Error: Could not load image ' . $file . '!');
		}


you could make that:

Code: Select all

		if (file_exists($file)) {
			$this->file = $file;

			$info = getimagesize($file);
			
			// image corrupt check
			if (!$info) error_log('cannot obtain image info for '.$file);
			
			$this->width  = $info[0];
			$this->height = $info[1];
			$this->bits = isset($info['bits']) ? $info['bits'] : '';
			$this->mime = isset($info['mime']) ? $info['mime'] : '';

			if ($this->mime == 'image/gif') {
				$this->image = imagecreatefromgif($file);
			} elseif ($this->mime == 'image/png') {
				$this->image = imagecreatefrompng($file);
			} elseif ($this->mime == 'image/jpeg') {
				$this->image = imagecreatefromjpeg($file);
			}
			
			// image corrupt check
			if (!$this->image) error_log('cannot create image '.$file);
			
		} else {
			exit('Error: Could not load image ' . $file . '!');
		}

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by letxobnav » Thu Aug 01, 2019 8:52 pm

and while you are there, better change these dumb statements:

Code: Select all

exit('Error: PHP GD is not installed!');
to

Code: Select all

error_log('Error: PHP GD is not installed!');

Code: Select all

exit('Error: Could not load image ' . $file . '!');
to

Code: Select all

error_log('Error: Could not load image ' . $file . '!');
no need to bring your site to a halt and displaying an embarrassing error message to the world.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: Bing [Bot], daniil_oc, drag84, WaxedPerfection and 471 guests