1007Regenerating Thumbnails in WordPress

Option 1: Plugin

The Regenerate Thumbnails Plug-in.

This option is usualy slower - and some hosting providers might confuse it for a malicious attach and block the IP.

Option 2: WP-CLI

WP-CLI is the command line interface for WordPress/ClassicPress.

Installation

From the WP-CLI Guide

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Run --info from your WP root directory, to check if it works:

php wp-cli.phar --info

If you get a json_encode error, it means your PHP version is not compatible with WP-CLI.

PHP 7 was the default on one server, it did not work.

Check for other PHP versions
which php
// /usr/bin/php

ls /usr/bin/php* 
// php80 php81 php82 php83

Let's use the latest verson of PHP.

php83 wp-cli.phar --info

Regenerating

Regenerate all images, without confirmation.

php83 wp-cli.phar media regenerate --yes

Regenerate thumbnails only.

$ php83 wp-cli.phar media regenerate --image_size=thumbnail

More options for regenerating images with WP-CLI:

# Regenerate thumbnails for given attachment IDs.
php83 wp-cli.phar media regenerate 123 124 125

# Re-generate all thumbnails that have IDs between 100 and 200.
seq 100 200 | xargs php83 wp-cli.phar media regenerate

# Re-generate all thumbnails that have IDs between 100 and 200.
seq 100 200 | xargs php83 wp-cli.phar media regenerate

# Re-generate all thumbnails that have IDs between 100 and 200, only thumbnails
seq 100 200 | xargs php83 wp-cli.phar media regenerate --image_size=thumbnail

#### Error

`Error: Error establishing a database connection.`

When working on _localhost_, use `127.0.0.1` instead of `localhost` in wp.config
```php
define( 'DB_HOST', '127.0.0.1' );

978Changing default Screenshot Form in OSX

Default format is PNG, change it to any of the following:

defaults write com.apple.screencapture type JPG
defaults write com.apple.screencapture type TIFF
defaults write com.apple.screencapture type GIF
defaults write com.apple.screencapture type PDF
defaults write com.apple.screencapture type PNG

First encountered here.

334Combining Images with UIImage & CGContext – (Offscreen drawing)

In Cocoa NSImage has a lockFocus method, that allows to draw images offscreen and combine them into one.

[img lockFocus];
//...
[img unlockFocus];

On the iPhone, UIImage lacks the lockFocus methods, instead the following:

// Create new offscreen context with desired size
UIGraphicsBeginImageContext(CGSizeMake(64.0f, 64.0f));

// draw img at 0,0 in the context
[img drawAtPoint:CGPointZero];

// draw another at 0,0 in the context, maybe with an alpha value
[another drawAtPoint:CGPointZero];

// ... and other operations

// assign context to UIImage
UIImage *outputImg = UIGraphicsGetImageFromCurrentImageContext();

// end context
UIGraphicsEndImageContext();

175Curling Images at Twitter

curl -F 'image=@test.png;type=image/png' -H 'Expect:' -u username:password http://twitter.com/account/update_profile_background_image.xml

hmm nice.

the logical thing to do.

instead of text messages, send images...

update: turning tiling on. curl -F 'image=@test.png;type=image/png' -F 'tile=true' -H 'Expect:' -u username:password http://twitter.com/account/update_profile_background_image.xml

second -F flag creates second form field.

update: same applies to user profile image curl -F 'image=@icon.png;type=image/png' -H 'Expect:' -u username:password http://twitter.com/account/update_profile_image.xml

update: absolute image paths curl -F 'image=@/Users/x/Desktop/icon.png;type=image/png' -H 'Expect:' -u username:password http://twitter.com/account/update_profile_image.xml

there seems to be a bug in the max shell object, preventing cd to work. it also does not like relative paths (~)...