WordPress There has been an error cropping your image

GD Graphics Library

I was updating my theme with the pretty amazing Twenty Seventeen from WordPress. Attempting to add a site icon it was just… failing. The blue select button in the Media Library would just go grey. When I tried a picture larger than 512×512 pixels I got a step further with the cropping dialogue, but then I’d get…

There was an error cropping your image.

It turns out WordPress needs the php-gd library for image manipulation.

First work out what php version you are running with

php -v

On Ubuntu/Debian hosts with php 5.x run

sudo apt-get install php5-gd

On RedHat/CentOS hosts with php 5.x run

sudo yum install php-gd

You may need to install specific packages like php56-gd for php 5.6. For php 7.x you will need to install php7.0-gd

Finally restart your web server

/etc/init.d/httpd restart

As an aside: I’m regretting my commitment to add an image to every post. What image makes sense with this post? The official logo for GD is 300×230 pixels.

How to remove double newline in text files

Last updated on July 5th, 2015 at 04:03 pm

As part of the hosting migration, I had some text files that had an extra empty line in them. This was caused by a newline followed by another newline.

On my pc I can search and replace for these using a good text editor. But it?s a bit harder to do on a linux command line.

The fix if it is just an empty new line is to use sed

sed '/^$/d'

as in

sed '/^$/d' < textfile.txt > newtextfile.txt

If the new lines have whitespace (a space or a tab) then use

sed '/^[ \t]*$/d'

You can also get information about the file with the file command

file textfile.txt
textfile.txt: ASCII English text

Beware if the output is

textfile.txt: ISO-8859 text, with CRLF, LF line terminators

as you?ll need to use

dos2unix textfile.txt

to convert it to a unix text file.

For people searching for the cause, most of these double new lines occured because a PHP script included another PHP script with require_once. The included PHP file had a whitespace at the end of the file after the



Determining PCI Vendor ID and Device ID

Last updated on July 4th, 2015 at 12:17 am

In working with LTSP and K12LTSP I use some old hardware as dumb terminals. Some of this old gear presents problems in determining the correct NIC driver or graphics driver to use.

If the old machine still has windows on it I use Craig?s PCI Programs to determine the Vendor ID and Device ID. I then go to PCI Database and look up the vendor ID/device ID pair. This works best for video drivers.

Alternatively I look up the Etherboot database to determine the best network driver.

Linux Terminal Server K12LTSP 4.4.1 Build notes

Last updated on June 28th, 2015 at 12:06 pm

This is for K12 Linux Terminal Server Project K12LTSP 4.4.1 running on Fedora Core 4. I downloded the CD images and burned them to 5 CD?s.

Boot from Disc 1 (of 5)

Hit enter to boot into Anaconda, Fedora?s graphical installer. You can cancel out of the installation at any point up to Required Install Media. Nothing is written to the drive until after that step, so if you get lost (or need to check something) just reboot and start again.

Welcome to Fedora Core Next

Language Selection: English (English) Next

Keyboard Configuration: U.S. English Next

Installation Type: Linux Terminal Server Next

Disk Partitioning Setup: Automatic partition Next

Automatic Partitioning: Remove all partitions on this system
I?m removing all vestiges of Windows from this server.
Tick Review (and modify if needed) the partitions created Next

Answer Yes to the Warning: You have chosen to remove all partitions (ALL DATA) one the following drives:
Are you sure you want to do this? Yes

Disk Setup review the partion information. Note the swap partion size is approximately twice the physical memory. If you expect to add more memory to the server soon, change the swap partion to be about twice the expected physical memory. Next

Boot Loader Configuration Accept the defaults for the Grub boot loader. Don?t bother with a password or advanced options. Next

Network Configuration Due to the nature of the networks I support, I don?t use DHCP for external connectivity. Normally the external port is eth1 if it is a PCI card and eth0 is on the motherboard. You can see the MAC addresses for each card by clicking the Edit button. I don?t like manually configuring local networks in the range to as there is too great a likelihood of clashes down the track, especially if you want to set up VPN access for mobile users who have LAN?s at home. Given the class C private range allows numbers to range up to I pick an IP address related to the postcode of the server?s location. In this test case it?s

As both ethernet cards have static IP addresses I give the server a manual hostname. e.g. ts27.zagz.com

Fill in the Gateway (to the internet – either a router or firewall), Primary, Secondary and Tertiary DNS. Blanks are OK for Secondary and Tertiary. Next

Firewall configuration My networks are protected by perimeter and departmental firewalls. I don?t want to jump through connectivity hoops right now so I select No firewall. This is not a good network practice, but I?m reviewing the network security at the moment so I?ll enable it later.

I also leave Enable SELinux Active. There is a performance hit of up to 7% by doing this. For a small network I?d probably leave it off. On these servers we?ll disable SELinux at the boot menu later. Next

Warning - No Firewall Against my own advice I click Proceed

Time Zone Selection Select the nearest city in your timezone. Check that your selection is correct in the scrolling Location box. Our clocks do no use UTC as local reporting tools can?t all adjust UTC to local time. Next

Set Root Password Do not pick a dictionary word or combination of them. Check your caps lock status especially if you can type without looking at the keyboard. Don?t show off, look and make sure you’re typing what you think you?re typing. Pick something with upper and lower cases plus numbers. Users can and will break this server if they can guess this password so don?t wimp out here. Next

Package Installation Defaults You can install the default packages, but we need to make some changes. There is a bug in this CD set that crashes anaconda if I select certain individual packages, so I make some minimum changes to get what I want and will add/remove apps later. Skip to the next point if you install the defaults.
Select Customize softwares packages to be installed Next
Tick KDE (K Desktop Environment)
Untick Sound and Video (we?re not enabling that for the thin-client workstations.
Untick Games and Entertainment
Tick Server Confiration Tools
Tick Windows File Server
Tick System Tools Click Details tick ethereal-gnome, rdesktop and VNC, then click OK
Untick Education
Click Next

About to Install Next

Required Install Media will list Fedora Core 4 CD #1 to #4 if you chose my selections. Click Continue

Go get coffee while the drive is formatted, the file systems prepared and things get copied to the hard drive.

Change discs when requested. Fedora like most modern distributions uses the discs in order and doesn?t ask for the same disc again later.

Click Reboot when the installation completes. Remember to take the disc out of the drive.

After the reboot
Welcome click Next

License Agreement Once you?ve read through the license agreement you can accept it and click Next. You do read any EULA?s that pop up on your systems don?t you?

Date and Time Make sure the current time is accurate. If your ISP provides a Network Time Protocol (NTP) server fill in the details in the tab. Unfortunately I haven?t been able to find the Telstra/Bigpond NTP server address. I?ll configure a public NTP server later. Next

Display As we are at the server monitor, I generally go for no greater resolution that 800?600 Millions of colours. But it doesn?t really matter unless someone is going to be working at the server in a pseudo peer-to-peer network. Next

System User You will set up users accounts later. Enter your everyday username here. Whether you will be a normal user or not, create an account here even if it it called ?support?. This is so you never log in as ?root?. Just don?t do it, it is wrong on so many levels. You?ll do administator tasks via the ?su -? command or their GUI equivalents. Next

Sound Card I don?t use sound on Terminal Servers. Next

Additional CDs. I don?t have any. Next

Finish Setup click Next

Fedora Login prompt appears.

Login as a user and install additional software in the folder on your Desktop. Install Adobe Acrobat, Flash and Fonts.

Next follow Stanton Finley?s excellent Fedora Core 4 Installation Notes for Yum to update the installation. Update: Read Stantion Finley?s site but beware of adding the repositories he mentions. It will kill your LTSP installation.
I?ll extend these LTSP installation notes over the next few days as our build continues.

D-Link multiport print servers

Last updated on August 21st, 2015 at 01:58 pm

I?m configuring a D-Link DP 300U multiport print server for use at home with OpenSuSE 10.0 and I thought I?d keep some notes on my linux adventures here.

DLINK print servers listen on ports 9100, 9101 and 9102 for multiport models and 9100 for the single port models

So all I have to do is configure my CUPS printing to point to theIP address of the print server and the port numbers are 9100 = LPT1; 9101 = LPT2 and 9102 = USB.

BTW the DP 300U defaults to but if someone else has configured it, the only way to reset it to factory default is to download the D-Link windows software from the D-Link site, connect the PC and the DP300U to a hub and let the software find it. Then you can configure the device.