Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stuck on large text file #68

Open
xeruf opened this issue Dec 10, 2021 · 17 comments
Open

Stuck on large text file #68

xeruf opened this issue Dec 10, 2021 · 17 comments

Comments

@xeruf
Copy link

xeruf commented Dec 10, 2021

When providing timg with a large text file, even when providing -t or --frames, it uses excessive CPU and calculates seemingly forever. Since I often use it for general file inspection, this is quite annoying.

@xeruf
Copy link
Author

xeruf commented Dec 10, 2021

Correction: the file does not have to be large. Even this takes quite long:

printf "#some\n#more\ntext\nhere we go" >/tmp/test.txt && timg /tmp/test.txt

Apparently it sometimes scrolls text as ASCII art and other times creates an image out of them, hm...

@xeruf
Copy link
Author

xeruf commented Dec 10, 2021

Using kitty btw

@hzeller
Copy link
Owner

hzeller commented Dec 10, 2021

I suspect that graphicsmagic is configured in a way to render a text as image.
It says here, that it can read txt files: http://www.graphicsmagick.org/formats.html

I couldn't reproduce this on my machine yet, so maybe there is a configuration which can be adapted ?

@xeruf
Copy link
Author

xeruf commented Dec 10, 2021

So apparently passing -V disables this, while timg will still display images and stuff just fine. This is a valid workaround for my case but would still be nice to fix this.

@xeruf
Copy link
Author

xeruf commented Dec 10, 2021

No special configuration afaik, using Kitty in Arch. What does the command I gave above do for you?

@hzeller
Copy link
Owner

hzeller commented Dec 10, 2021

I could reproduce this now; I was compiling timg under nixos with a limited set of Graphicsmagic filters, so it just returned and didn't show the image as it usually just skips images it can't decode.

Now on regular debian, I can see that it renders the text as image, which probably can take a while.
I suspect somewhere in /usr/share/GraphicsMagick-*/config/ graphicsmagic can be configured somehow to not process certain image types.

@xeruf
Copy link
Author

xeruf commented Dec 11, 2021

For me these files are essentially empty though:

<?xml version="1.0"?>
<!--
Color definition file.  Definitions in this file extend or replace the
compiled in color definitions.  Use 'gm convert -list color' to list
the currently available colors.  This file is optional and the
software will still function if it is removed.

For example:

<colormap>
  <color name="mycolor1" red="228" green="118" blue="33" compliance="None" />
  <color name="mycolor2" red="228" green="123" blue="66" compliance="X11" />
</colormap>
-->
<colormap>
</colormap>
<?xml version="1.0"?>
<!--

                 GraphicsMagick Logging Configuration File

The following options are available:

  o events [comma separated list]
      annotate       Text annotation events.
      blob           File opening/closing/loading events.
      cache          Pixel cache events.
      coder          File format coder events.
      configure      Configuration events (searching for .mgk files, etc.).
      deprecate      Identify use of deprecated functions.
      error          Error exception report events.
      exception      Exception report events (warning and error).
      locale         Locale events.
      none           Reporting disabled.
      render         Rendering (drawing) events.
      resource       Resource allocation events (memory, disk, etc.)
      temporaryFile  Temporary file events (allocate, deallocate, etc.)
      transform      Image processing events.
      user           User events (not emitted by GraphicsMagick).
      warning        Warning exception report events.
      X11            X11 server events.

  o output
      none           Reporting disabled.
      disabled       Reporting disabled.
      stdout         Log to stdout in "human readable" format
      stderr         Log to stderr in "human readable" format
      xmlfile        Log to a file in an XML format
      txtfile        Log to a file in a text format
      win32debug     Windows, Output events to the application/system debugger.
      win32eventlog  Windows, Output events to the Application event log.

  o Filename - Use specified filename if output to a file is selected.
    Place a %d in the file name in order to support multiple log generations.

  o Generations - Number of log files to maintain before circulating back to
      the first name.

  o Limit - Maximum number of logging events before creating a new log file.

  o Format - Format of logging output

      You can display the following components by embedding
      special format characters:

        %d   domain
        %e   event
        %f   function
        %l   line
        %m   module
        %p   process ID
        %r   real CPU time
        %t   wall clock time
        %u   user CPU time
        %%   percent sign
        \n   newline
        \r   carriage return

 -->
<magicklog>
  <log events="None" />
  <log output="stderr" />
  <log filename="Magick-%d.log" />
  <log generations="3" />
  <log limit="2000" />
  <log format="%t %r %u %p %m/%f/%l/%d:\n  %e"  />
</magicklog>
<?xml version="1.0"?>
<!--
  Magick Module Alias Map (modules.mgk)

  Provides a mapping from a magick format identifier string to the
  name of the loadable module which supports it.  This allows a module
  to support formats other than its own name.  This file is optional
  and the software will still function if it is removed.

  Entries are of the form:

  <module magick="MYMAGICK" name="MYMODULE" />

-->
<modulemap>

</modulemap>

@xeruf
Copy link
Author

xeruf commented Dec 15, 2021

Yeah so the workaround is not okay as it disables EXIF rotation, this needs a proper fix

@hzeller
Copy link
Owner

hzeller commented Dec 20, 2021

So if we had an option that would exclude certain suffixes, would that help ? Say -X.txt ?

@xeruf
Copy link
Author

xeruf commented Dec 23, 2021

Not sure what you mean by that, but that probably won't help. Can't you force the scrolling on text rather than conversion to an image?

@hzeller
Copy link
Owner

hzeller commented Dec 23, 2021

What I mean is essentially disallow certain file suffixes that are then not shown (and maybe an environment variable to store that in so that it doesn't have to be typed every time).

The idea of detecting text and show it in a different way also sounds good, but it would take a bit longer (as it essentially still has to obey the frame-width constraint)

hzeller added a commit that referenced this issue Dec 24, 2021
Files with file-ending of "txt" are now considered multi-frame
images not displayed as animation. That allows all of them to be
shown and not get stuck in a forever-animation if this is the
only file given on the command line

Issues #68
@hzeller
Copy link
Owner

hzeller commented Dec 24, 2021

As a first step, I've now added that files ending with txt are not considered as 'animation' but as 'multi image'. Problem with long text files was that they end up multiple image frames which were shown as animation (and thus loop forever), while as multi-image, all the rendered frames are shown (also without delay). At least that helps not to 'get stuck' on a single text file.

@xeruf
Copy link
Author

xeruf commented Jan 4, 2022

Unfortunately most text-files don't end in .txt, but that sounds like a good first step.
A new releases would be nice ;)

@hzeller
Copy link
Owner

hzeller commented Jan 8, 2022

Alright, new release: https://github.com/hzeller/timg/releases/tag/v1.4.3

@xeruf
Copy link
Author

xeruf commented Aug 2, 2022

If I now run on version 1.4.4:

printf "#some\n#more\ntext\nhere we go" >/tmp/test.txt && timg /tmp/test.txt

I get a picture, probably from imagemagick, rather than scrolled ASCII, which I would have preferred, is that intended?

@hzeller
Copy link
Owner

hzeller commented Aug 2, 2022

Yes, there is currently no attempt to interpret files anything other than images. So indeed, imagemagick will convert it into multiple images that then scroll.

@xeruf
Copy link
Author

xeruf commented Aug 3, 2022

But what about the ASCII-art scrolling, I thought you could handle it like that as I already saw in some other text files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants