npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

animate-embed-images

v1.0.2

Published

Module for Adobe Animate that inserts image assets inside js file

Downloads

4

Readme

Animate. Embed Images

Module for Adobe Animate that inserts image assets inside js file

Helpful stuff when you need to get single html without external files. Maybe some day Adobe will add this feature.

preview

Installation

npm install animate-embed-images

Output example (part of...)

lib.properties = {
   width: 300,
   height: 500,
   fps: 24,
   color: "#FFFFFF",
   opacity: 1.00,
   webfonts: {},
   manifest: [
      {type:createjs.AbstractLoader.IMAGE, src:"data:image/png;base64, ... ", id:"Bitmap1"},
      {type:createjs.AbstractLoader.IMAGE, src:"data:image/png;base64, ... ", id:"Bitmap2"},
      {type:createjs.AbstractLoader.IMAGE, src:"data:image/jpg;base64, ... ", id:"Bitmap3"},
   ],
   preloads: []
};

Usage

const path = require('path');
const glob = require('glob');
const chalk = require('chalk');
const {table, getBorderCharacters} = require('table');
const AnimateEmbedImages = require('animate-embed-images');

glob('test/**/!(*.b64).js', (err, files) => {
   for(let i = 0, len = files.length; i < len; i++){
      let js_file = path.join(__dirname, files[i]);
      
      new AnimateEmbedImages(js_file, js_file.replace(/\.(js|html?)$/i, '.b64.$1'))
      .then(data => {
         let table_data = [[chalk.white.bold('N'), chalk.white.bold('SIZE (base64)'), chalk.white.bold('FILE')]];
         let diff_summ = 0;
         for(let i = 0, len = data.images.length; i < len; i++){
            let file = data.images[i];
            let diff = file.b64_size / 1024 || 0;
            diff_summ += diff;

            table_data.push([i + 1, chalk.yellow.bold(diff.toFixed(3) + ' KB'), file.name]);
         }

         console.log('');
         console.log(' ' + chalk.white.bgGreen.bold(' ' + data.message + ': '), chalk.white.bgBlue.bold(' +' + (diff_summ).toFixed(3) + ' KB '), path.basename(data.input_file));
         console.log(table(table_data, {columns: {0: {width: 3}, 1: {width: 15}, 2: {width: 50, truncate: 50}}, border: getBorderCharacters('ramac')}));
      })
      .catch(data => {
         let table_data = [[chalk.white.bold('N'), chalk.white.bold('SIZE'), chalk.white.bold('FILE')]];
         for(let i = 0, len = data.images.length; i < len; i++){
            let file = data.images[i];
            table_data.push([i + 1, '-', chalk.red.bold(file.name)]);
         }

         console.log('');
         console.log(' ' + chalk.white.bgMagenta.bold(' ' + data.message + ': '), path.basename(data.input_file));
         console.log(table(table_data, {columns: {0: {width: 3}, 1: {width: 15}, 2: {width: 50, truncate: 50}}, border: getBorderCharacters('ramac')}));
      });
   }
});

Callback data structure:

{
   status         -> {String} 'ok' or 'fail'
   message        -> {String} Any text describing status
   input_file     -> {String} Source js file path
   output_file    -> {String} Output js file path
   js_content     -> {String} Modified js content
   images: [
      {
         name     -> {String} Image file name
         path     -> {String} Image path
         exist    -> {Number} 0 - if image does not exist
         size     -> {Number} Image file size (bytes)
         b64_size -> {Number} The size of the image in base64 format (bytes)
      }
   ]
}

Changelog

2018-01-17:

  • Removed images sorting. That was just for cosmetic purposes at the debug stage.