jeudi, décembre 29 2011

Fixing pictures resolution issues with Windows Live Writer

While travelling a few years ago we extensively used Windows Live Writer to quickly post new blog articles including picture onto our blog.

Due to bandwidth constraints, we did not want to upload huge pictures each time and therefore set a maximum picture size of 640x480 for the biggest images. Now that we’re in the process of making a book using Blurb, we get into troubles as 640x480 is definitely not good enough for a printed media.

Instead of matching manually all pictures, I took a different approach as I had all my blog articles saved in My Documents\My Weblog Posts as .wpost files.

Opening these files in 7-zip shows that it’s a compressed zip files containing all the blog information under as a file structure. Worth mentioning aside the obvious is the ServerSupportingFileDir which contained the path on the server where these files were saved.

image

The subfolder SupportingFiles contains a folder per attached file where the file content and file name are stored.

Based on this, I quickly wrote two scripts:

  1. The first decompresses all the wpost files using 7-Zip
  2. The second parses the decompressed files, extracts all pictures and saves them in a file structure identical to that on the website.

The last operation is to upload these new files per FTP, so that we get a much better image resolution (Windows Live Writer saving all the picture at least with 1024x768px).

As you can see, there were a few issues along the way, such as converting the files from  Unicode encoding to ASCII and some file extensions issues, but they were all resolved within the batch file.

First script - extractJPGs.bat

rem sets the proper working folder
cd /d %0\..
cd %0\..
rem Define the path to the 7-zip command line executable
set z="c:\program files\7-zip\7z.exe"

rem loops through all the *.wpost files and decompresses them, without extension, into the temp file
for /r . %%f in (*.wpost) do %z% x "%%f" -o"temp\%%~nf\"


pause

Second script - renameAndMoveJPGs.bat

@echo off
rem sets the proper working folder
cd /d %0\..
cd %0\..\temp

rem iterates through all the folders and calls handleFolder with the directory's name
for /d %%d in (*) do call :handleFolder "%%d"

goto :eof

:handleFolder
    echo %1
    cd %1
    rem The standard file is not ASCII encoded. We need to make an ASCII compliant copy of it via type
    type ServerSupportingFileDir > ServerSupportingFileDir_v2

    rem We store the folder name of the server withint the uploadFolder variable
    set /p uploadFolder=<ServerSupportingFileDir_v2
   
    rem For each found file matching "SupportingFileName", we call the handleFiles with the file name and upload folder as argument
    for /r . %%f in (SupportingFileName) do call :handleFiles "%%f" "%uploadFolder%"
    echo %uploadFolder%
    cd ..
    rem pause
    goto :eof

:handleFiles
    if exist %1    call :handleFiles2 %1 %2
    goto :eof
   
:handleFiles2
    rem echo on
    rem Stepping into the current folder
    cd %1\..

    rem The standard file is not ASCII encoded. We need to make an ASCII compliant copy of it via type
    type %1 > %1_v2

    rem We store the file name within the variable
    set /p fileName=<%1_v2

    rem We create the output folder
    if not exist ..\..\..\..\forWeb\%2 mkdir ..\..\..\..\forWeb\%2

    rem Quick trick - during the copy, we don't fully rely on the file extension found in the file.
    rem I had quite a few .JPG files according to SupportingFileName, but on the server they were known as .jpg.
    rem We therefore take all the filename but the last 3 characters and force our own file extension.
    copy SupportingFileContents ..\..\..\..\forWeb\%2\%fileName:~0,-3%jpg
    cd ..\..
    goto :eof
   
:eof

samedi, septembre 17 2011

Seul regret avec Android 2.3 sur Xperia x10

La mise à jour vers Android 2.3 pour un possesseur d’Xperia x10 vaut vraiment la peine car de nombreux avantages sont présents avec la nouvelle version.

Voici ma liste toute personnelle:

  • Interface améliorée
  • Durée de vie de la batterie allongée
  • Possibilité de partager la connexion Internet via le WiFi (alias “wifi tethering”)
  • Navigation Internet nettement plus rapide, notamment dans le chargement des pages

Le seul regret que j’ai à exprimer pour cette version est l’absence pour cause de non-compatibilité avec Android 2.3 de l’application Panorama beta de Sony Ericsson qui permettait de faire facilement et rapidement des chouettes panoramas!

image

mercredi, août 3 2011

Mise à jour Android 2.3 disponible pour l'Xperia 10 chez Swisscom

Après de multiples annonces ces dernières semaines, ça y est enfin: la mise à jour Gingerbread est disponible pour mon téléphone Swisscom.

La mise à jour s’est déroulée sans aucun soucis mais la reconfiguration du téléphone me prendra un petit moment.

Pour mémoire, voici les informations techniques après mise à jour:

Numéro du modèle: X10i

Version d’Android: 2.3.3

Version de bande de base: 2.1.71

Version du noyau: 2.6.29-00054-g5f01537 SEMCUser@SEMCHost#1

Numéro de build: 3.0.1.G.0.75

- page 1 de 5