`uploads:regenerate_missing_optimized` fails to generate missing optimized images

rake uploads:missing found 225 missing optimized images, all of them named *10x10.png

Attempt to regenerate missing files using rake uploads:regenerate_missing_optimized produces 225 errors of type: ‘convert: improper image header’ and ‘convert: no images defined’ in the error log. Version 2.4.0.beta10 (c5e3faac00)

hostname	discourse-app
process_id	9853
application_version	6455c6ee872109fc3da9a2b45f6b7466bb96c123
location	/var/www/discourse/public/uploads/default/optimized/2X/9/97f2e2dfda850e56bf8ef65cfc7ee2c885285b4b_2_10x10.png
error_message	lib/discourse.rb:57:in `exec': convert: improper image header `/var/www/discourse/public/uploads/default/original/2X/9/97f2e2dfda850e56bf8ef65cfc7ee2c885285b4b.jpg' @ error/png.c/ReadPNGImage/4294. convert: no images defined `png:/var/www/discourse/public/uploads/default/optimized/2X/9/97f2e2dfda850e56bf8ef65cfc7ee2c885285b4b_2_10x10.png' @ error/convert.c/ConvertImageCommand/3273.
time	7:22 am

Backtrace from the logs:

lib/discourse.rb:644:in `block in warn'
lib/discourse.rb:638:in `each'
lib/discourse.rb:638:in `warn'
/var/www/discourse/app/models/optimized_image.rb:350:in `rescue in convert_with'
/var/www/discourse/app/models/optimized_image.rb:332:in `convert_with'
/var/www/discourse/app/models/optimized_image.rb:327:in `optimize'
/var/www/discourse/app/models/optimized_image.rb:307:in `resize'
/var/www/discourse/lib/tasks/uploads.rake:467:in `block (2 levels) in regenerate_missing_optimized'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/batches.rb:70:in `block (2 levels) in find_each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/batches.rb:70:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/batches.rb:70:in `block in find_each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/batches.rb:136:in `block in find_in_batches'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/batches.rb:238:in `block in in_batches'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/batches.rb:222:in `loop'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/batches.rb:222:in `in_batches'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/batches.rb:135:in `find_in_batches'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/activerecord-6.0.1/lib/active_record/relation/batches.rb:69:in `find_each'
/var/www/discourse/lib/tasks/uploads.rake:436:in `block in regenerate_missing_optimized'
/var/www/discourse/lib/tasks/uploads.rake:435:in `each'
/var/www/discourse/lib/tasks/uploads.rake:435:in `regenerate_missing_optimized'
/var/www/discourse/lib/tasks/uploads.rake:406:in `block (2 levels) in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.0.7/lib/rails_multisite/connection_management.rb:63:in `with_connection'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rails_multisite-2.0.7/lib/rails_multisite/connection_management.rb:73:in `each_connection'
/var/www/discourse/lib/tasks/uploads.rake:406:in `block in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `block in execute'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:281:in `execute'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/task.rb:188:in `invoke'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:160:in `invoke_task'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `each'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:116:in `block in top_level'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:125:in `run_with_threads'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:110:in `top_level'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:83:in `block in run'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/var/www/discourse/vendor/bundle/ruby/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
bin/rake:13:in `<top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/lib/bundler/cli/exec.rb:63:in `load'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/lib/bundler/cli/exec.rb:63:in `kernel_load'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/lib/bundler/cli.rb:476:in `exec'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/lib/bundler/cli.rb:30:in `dispatch'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/lib/bundler/cli.rb:24:in `start'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/exe/bundle:46:in `block in <top (required)>'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/usr/local/lib/ruby/gems/2.6.0/gems/bundler-2.1.1/exe/bundle:34:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'

These are the files on disk (for one such image)—note the 0 KB 10x10 png:

Optimized (shared/standalone/uploads/default/optimized/2X/9/):

97f2e2dfda850e56bf8ef65cfc7ee2c885285b4b_2_690x517.jpeg 172 KB
97f2e2dfda850e56bf8ef65cfc7ee2c885285b4b_2_667x500.jpeg 163 KB
97f2e2dfda850e56bf8ef65cfc7ee2c885285b4b_2_10x10.png      0 KB

Original (shared/standalone/uploads/default/original/2X/9/):

97f2e2dfda850e56bf8ef65cfc7ee2c885285b4b.jpg   94 KB

OK so what’s the problem? Just ignore those malformed images and carry on.

(Or edit them out of they posts they are probably in?)

1 Like

These are not malformed images, they display correctly in the post.

What is malformed (or rather not generated) is the ‘quick scroll’ optimised image, which fails to generate from the original.

It can be detected as missing when quick scrolling through the post.

I have edited the title for clarity.

2 Likes

Hi, @md-misko
Did you happen to solve your problem?
I happen to face similar issues.

I have since migrated to S3 and cannot run rake uploads:missing anymore against the S3, but I’ve checked the one file referenced above and it has a non 0 size on S3 now, so it seems this was fixed.

Are you on latest build?

2 Likes

Oh! I didn’t know that this command isn’t meant for S3 buckets.

Yes. I always keep upgrading to the latest. At the most, I may be behind 2-3 days sometimes.

In any case, if you might happen to know, what’s the best command to find the missing uploaded images, or what is the command to map the posts urls to correct images in the correct basket (if for some reason the paths got corrupt)?

This seems unrelated to the issue described in the OP, perhaps open a new topic in support and describe exactly what your problem is.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.