Showing posts with label LibreOffice. Show all posts
Showing posts with label LibreOffice. Show all posts

Monday, October 19, 2015

Quickly generate a spreadsheet of image properties from a large number of images

Recently there was a need to find out some image properties e.g. the pixel width and height of a large number of photo images. In Windows Explorer, you could enable the Dimensions property to be displayed in the detail view, but you could not do too much with it. You could not do additional calculations on top of the view.

Fortunately, ImageMagick has an identify command to print out information about one or more images. The following shows how to use identify to print out the image file names and dimensions.


  1. Open up a Command Prompt.
  2. At the prompt, type in the command e.g.

    C:\> identify -ping -format "%i,%w,%h\n" *.jpg

    Note: the ping option will prevent the loading of the entire file.
    The format string has place holders for the properties to be printed.
    %i is for the image filename
    %w is for the image width
    %h is for the image height
    And optionally some delimters such as commas between the properties and terminated with a new line character
    '\n'.
    For more information about the string format placeholders, visit http://www.imagemagick.org/script/escape.php
  3. Press RETURN to run the command.

    The information is printed to the screen.

  4. If you want to print the information to a file, type in the following command.

    C:\> identify -ping -format "%i,%w,%h\n" > output.csv
  5. The resultant file can be displayed and further manipulated in a spreadsheet as shown below.



Monday, May 13, 2013

Export a LibreOffice Base table as a CSV file

Previously I use Microsoft Access to manipulate and export out table data as comma separated values (CSV) files. I decided to use LibreOffice Base to do the same thing. It wasn't difficult to create CSV files in LibreOffice but the concept is different than Microsoft Office's. In LibreOffice, you have to create the text file document first before dragging the source table into the document. It took me a while to figure this out. The following steps illustrate how to do it.

  1. Click Start | All Programs | LibreOffice 4.0 | LibreOffice.

    LibreOffice appears.

  2. Click Text Document.

    A blank Writer document appears.

  3. Press F4.

    The Data Source pane appears.

  4. Expand the database nodes until the desired table e.g. biblio, is visible.


  5. Drag and drop the table onto the blank document.

    The Insert Database Columns dialog box appears.

  6. Toggle on Text.
  7. Select a Database column to export, e.g. Booktitle. Then click >. Repeat for additional columns, e.g. Author and Publisher.
  8. Edit the format string to include a comma or any other delimiter between the columns.


  9. Click OK.

    The table data is placed on the document.

  10. Select File | Save As.

    The Save As dialog box appears.

  11. Type in a file name e.g. mycsvfile. Choose the type as Text. Click Save.

    The CSV file is created.

Monday, May 6, 2013

Import a CSV file into LibreOffice Base

After using Microsoft Access for many years, I decided to give LibreOffice Base a spin. One of the usual task I do with Access is to import a Comma Separated Values (CSV) file into an Access *.mdb database, where I could run some SQL queries on it. I wanted to do the same thing using Base. It turned out that I could copy and paste the CSV file via a LibreOffice Calc spreadsheet, but a better way is to simply open the CSV file directly, as shown below.

The example CSV file is shown in the screenshot below.


  1. From the Start button, select All Programs | Libre Office 4.0 | LibreOffice Base.

    The Database Wizard appears.

  2. Toggle on Connect to an existing database. Choose Text. Click Next.
  3. In the Path to text files field, click Browse. Select the folder containing the CSV file, e.g. D:\Temp\myfolder\. Click OK.


  4. If necessary, choose the CSV type e.g. Plain text files (*.txt). Choose the CSV separator formats. Click Next.


  5. Click Finish.

    The Save As dialog box appears.
  6. Type in a new file name, e.g. D:\Temp\csv.odf. Click Save.

    The database is created and the CSV file can be seen as a table.




    Note: this CSV database is read-only. 
  7. Now, create or open up an existing Base database, e.g. New database.odf in another window.


  8. Simply drag and drop the CSV table to the newly opened Base window's Tables icon or pane.

    The Copy table dialog box appears.

  9. Optional. In the Table name field, type in a new name.
  10. Click Next.

    The Apply columns appear.

  11. Click the >>.

    All the columns are moved to the right.
  12. Click Next.


  13. Optional. Type in a new field name and change the type or length if necessary.
  14. Click Create. Optional. When prompted to create a primary key, click Yes to create or No to ignore.

    The CSV file is imported into the Base database.