TinyURL widget - shorten your URL's for free!

Enter a long URL to make tiny:

Wednesday, April 8, 2015

ERROR: Mimetype entry missing or not the first in archive EPUB


When you extract files from an EPUB, fix them and update the archive, that changes the ordering inside.

When you try to submit a revised EPUB, you will get this error:

ERROR: Mimetype entry missing or not the first in archive

To fix it, extract all content and make a new archive with an UNCOMPRESSED mimetype file FIRST like so in Linux/Unix/Apple:

zip -X0 book.epub mimetype

then remove the mimetype from the contents and add the rest like this:

zip -X8Dur book.epub *

That should refresh the order and compress all the other files.

Monday, April 6, 2015

Blogger can show animated GIF of about 12MB

This Animated GIF is about 12 MB.


Correct Video Sequence Names in OpenShot

I used this post to make this animated GIF:



And this longer one



My previous posts dealt with how to make an animated GIF.

I use openshot to convert a video sequence into a image sequence.

There is a problem with the default naming sequence for openshot.  If you leave it as default it uses the printf number format:

%d

which then puts  __1.png

besides    _100.png

in the sequence.


It is set in the export menu






Instead, increase the number format to have say 4 digits which will be zeros preceding the number like this

%4d

instead of

%d

It is using good ol C printf format so this will make the right sequence like so:








Saturday, April 4, 2015

How to make Animated GIFs Part 2

Ok;


This summarizes the work in past posts, I have made an animated GIF from Call of Duty: Advanced Warfare and I used this post:

http://techdiagnosys.blogspot.ca/2015/04/bash-shell-scripting-read-all-files-in.html


to remove every nth file from a series of PNG files and then I used ImageMagick to convert them into an animated GIF with a reasonable loop speed.

I use this post to convert:

http://techdiagnosys.blogspot.ca/2015/04/how-to-make-animated-gif-using-image.html

I could iterate the .png file reduction by every 3, 4 or 5 files recursively until down to the right size.

I know that blogger can upload files up to 45MB animated GIFs since that's what this one above is.

I hope this helps you and most likely me when I forget how to do this.





BASH Shell scripting: read all files in directory, read files of .suffix, remove the nth file, and output count

BASH is hard for beginners and even pros; unless you were taught all the contexts of data and variables, then it's hard to remember which circumstance makes sense.

The biggest problem with Linux is the powerful tools matched with skimpy documentation.  It resides in the brains of people that forget to pass it on.

Or, perversely, the people that want to hoard the information and make you beg them to reveal it.  I really don't like that attitude from the older SYSV crowd, they seem to be helping by answering questions but it would be better to take the time and write out complete methodical examples. And to explain step by step.

The unix community has a penchant for Munchausen syndrome. It has a need to be asked for help rather than just being helpful.

I would recommend if you are trying to learn to make simple examples with the dangerous parts left out and build up functionality from simple parts.

For these examples, I started making a shell script that could read files, then read certain files, then read and delete certain files.  I made lots of mistakes and the directory was placed in /tmp in case I toasted it.

This script would be good for someone trying to make a GIF from a series of image files. Sometimes people that want to do the functionality but don't want to learn a language this is a good post for that.

I made this really bad animation removing every third file over and over unto a nonsensical mess but it made an interesting GIF.





This shellscript reads all files of any type (not hidden) in the present working directory and echos the file name and increments a counter.

At the end, it outputs the count of files:


#!/bin/bash
x=0
FILES=./*        # BASH resolves variable for you
for  f in $FILES
do
    echo $f        # iterates through and echoes
    ((x++))         # postincrements counter for all type file
done
echo "$x"

You can find this file here

If you want read and count files of a certain .suffix then  send it as a command line argument in this case $1 first arg. NOTE: don't include the '.' !

#!/bin/bash
# this version reads files of a certain .suffix passed as arg $1
x=0
FILES=./*.$1        # BASH resolves variable for you
for  f in $FILES
do
    echo $f        # iterates through and echoes
    ((x++))         # postincrements counter for all type file
done
echo "$x"
You can find this file here

For a good tutorial of if then constructs go here:

If you want to iterate through and remove every nth file in that file list with the suffix, then execute this shellscript:

#!/bin/bash
# DRE 2015 - Thinking, Realizing, Reacting
# this version reads files of a certain .suffix passed as arg $1
x=0
y=0
n=$2
echo $n
FILES=./*.$1        # BASH resolves variable for you
for  f in $FILES
do
    echo $f        # iterates through and echoes
    ((x++))         # postincrements counter for all type file
    if ((x%n == 0))  ;  then  # test for file increment and execute
        rm -f "$f"   # you need to quote filename variable to get name in proper format to rm command
        ((y++))    
    else
        :   # this is the BASH no operation (NOOP) command
    fi
done
echo files count: "$x"
echo files removed : "$y"
You can find this file here


TO RUN THIS COMMAND, Open a SHELL and type:

sh ~/shellscripts/remove_n_file.sh png 3

( I put all my shell scripts into a common folder shellscripts. Your placement will vary command. )

inside the directory with a series of PNG image sequence files.  This will look for all .png files and removes every 3rd one. mod 3 for this example.

So if you have 2100 files, the first run through of the script would remove about 700 files.  Note that the contents would still be in sequence.  Then, if you wanted to reduce them further just do this again and again and it will remove from the same sequence over and over. You can compensate for varying the loop delay time with Image Magick. Of course if you thin out too many images the sequence will go really fast and may not work right.  This is the art of the process. 

To make a good motion animated GIF you should be looking at a sequence that's a few second in video length.

This shell script takes 2 variables, the suffix first and then the number file to delete.

Note for sake of simplicity there is no error checking here so you can destroy the contents you are working on. Use against a copy folder!  This is a tutorial not a production shell script.

The tricks are you use the (()) C argument mode to evaluate math properly, so you don't need $variable names but the actual variables.

You need to quote the $f filename to send it resolved to remove command.


NOTE:

This shellscript DOES work on ubuntu 14.10 with:

 bash --version
GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

If you change the downloaded file permission to executable

chmod u+x remove_n_file.sh

to allow it to run and run without sh

~/shellscripts/remove_n_file.sh png 3

and it does work on Fedora 20 with:

 bash --version
GNU bash, version 4.2.53(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


How to make an animated GIF using Image Magick

HOW TO MAKE SIMPLE  ANIMATED GIF USING CONVERT - IMAGE MAGICK




This is for someone using ImageMagick on linux, sorry Windows people I don't know if this works on Windows.

1. Create a sequence of same size jpg files.



2. Move all files into one directory

3. Rename then to a sequence name%d.jpg file list


4. Then run from command line:

convert -delay 100 -loop 0 image*.jpg animation.gif

http://books.google.ca/books/about?id=_CbHBwAAQBAJ&redir_esc=y
Animation.gif with .png files