From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tomas Hlavaty Newsgroups: gmane.emacs.devel Subject: Re: Implementing image support for kitty terminal Date: Thu, 08 Sep 2022 22:03:41 +0200 Message-ID: <875yhxeiqq.fsf@logand.com> References: <87v8pz18wf.fsf@mail.jao.io> <83o7vrgimc.fsf@gnu.org> <87wnafdnee.fsf@logand.com> <87a67bymys.fsf@mail.jao.io> <87h71hekyu.fsf@logand.com> <837d2dekao.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24431"; mail-complaints-to="usenet@ciao.gmane.io" Cc: jao@gnu.org, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Sep 08 22:05:50 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oWNmY-0006Bm-HI for ged-emacs-devel@m.gmane-mx.org; Thu, 08 Sep 2022 22:05:50 +0200 Original-Received: from localhost ([::1]:51770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oWNmW-0004QZ-PK for ged-emacs-devel@m.gmane-mx.org; Thu, 08 Sep 2022 16:05:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWNkc-0002wX-GS for emacs-devel@gnu.org; Thu, 08 Sep 2022 16:03:52 -0400 Original-Received: from logand.com ([37.48.87.44]:42856) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oWNka-0002Df-Pz; Thu, 08 Sep 2022 16:03:50 -0400 Original-Received: by logand.com (Postfix, from userid 1001) id 281E41A1793; Thu, 8 Sep 2022 22:03:43 +0200 (CEST) X-Mailer: emacs 28.1 (via feedmail 11-beta-1 I) In-Reply-To: <837d2dekao.fsf@gnu.org> Received-SPF: pass client-ip=37.48.87.44; envelope-from=tom@logand.com; helo=logand.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:295009 Archived-At: On Thu 08 Sep 2022 at 22:30, Eli Zaretskii wrote: >> From: Tomas Hlavaty >> Cc: emacs-devel@gnu.org >> Date: Thu, 08 Sep 2022 21:15:37 +0200 >> >> The problem is, that that capability is not available in tty emacs: > > Yes, it _is_ available. We just suppress it. Interesting, is it possible to somehow "un-suppress" it? >> (image-size (create-image "/tmp/a.jpg")) >> => (error "Window system frame should be used") > > This is us deliberately failing image-size early on, because we don't > want complications down the road, and because we know images cannot be > displayed on TTY frames. I am asking emacs to tell me the size of the image. I am not asking emacs to display it. >> Would it be possible to fix that? > > I don't see why it would be hard. E.g., this works just fine in a -nw > session: > > (create-image "/tmp/a.jpg") Why does create-image work and image-size does not? Why is this not "us deliberately failing create-image early on, because we don't want complications down the road, and because we know images cannot be displayed on TTY frames."? Also this returns: (image :type jpeg :file "/tmp/a.jpg" :scale 1 :transform-smoothing t) which does not tell me image width and height that I'd like to know. >> > and, if >> > those libraries are not available, a call to "file foo.png" is (at least >> > in my system) telling me the size of foo.png... kind of hacky, of >> > course, but as a first step maybe good enough. >> >> This is the easy part. Then you need to change the existing emacs C >> code to actually call that. >> >> (btw isn't the file program potential security issue?) > > We don't need 'file', Yes, that was my point. > Emacs already knows how to compute the size of an image. So how do I get the size of an image? My tty emacs does not know that, I get this error: (image-size (create-image "/tmp/a.jpg")) => (error "Window system frame should be used") Maybe tty emacs already knows how to compute the size of an image, but I have not figured a way of asking my tty emacs to share that information with me. Is there a way?