I am trying to figure out the best way to upload and show images in articles. Right now I have the following code under the apostrophe-blog-pages show.html template
<div>
{{ apos.area(data.piece, 'main', {
widgets: {
'apostrophe-rich-text': {
toolbar: [ 'Styles', 'Bold', 'Italic', 'Blockquote', 'Link', 'Anchor', 'Unlink', 'Table', 'BulletedList', 'NumberedList' ],
styles: [
{ name: 'Title', element: 'h3' },
{ value: 'h5', label: 'Subtitle' },
{ name: 'Paragraph', element: 'p' }
]
},
'apostrophe-images': {
size: 'original'
},
'apostrophe-video': {}
}
}) }}
</div>
The issue that I am facing is that I have images with different size and aspect ratio. And apostrophecms or imagemagick automatically decides what the actual aspect ratio of an image should look like and for bigger images it works fine but for smaller image (usually less that 400 px size) images show up pixelated or zoomed in.
Not sure what is the best to show images with their original height and width.
As you know I am the lead developer of Apostrophe at P'unk Avenue.
In the code you gave, Apostrophe is not actually touching your aspect ratio or image sizes in any way. You are setting size to original and you have not set either minSize or aspectRatio, so Apostrophe really has no opinion about your image.
We actually strongly discourage the use of original unless you have a very, very good reason for making your users think extra-hard about the right size of image to upload. If you let your users upload their best image (well, up to about 2000x2000 or so...) and use Apostrophe's sizes like one-half, full and max, and use CSS for the final adjustment, you'll get good page-loading speed without the need for the admin of the site to pre-size everything in Photoshop.
But again... nothing in your code here is cropping the image in any way.
If you think there's a bug here, in that Apostrophe is cropping where it should not be, please prepare a test project in github and open a github issue on the apostrophe project with the details.
Thanks!
Not the best solution but since the issue was with the CSS style. I had to overwrite the img width style and the change fixed the issue.
.apos-slideshow .apos-slideshow-item img {
width: auto !important;
}
Related
so I have been making some image requests with the google docs api using javascript, but I have been unable to change the image size when I make the request.
All the images seem to be appearing in their original size in the google doc.
So I am wondering what I am doing wrong. The documentation seems to be pretty clear:
https://developers.google.com/docs/api/reference/rest/v1/documents/request#InsertInlineImageRequest
Basically it just says to specify objectSize width and height, using magnitude and units (PT).
Here is the function I use to append to my full request, where I specify all of these.
function imageRequest (url: string, width: number, height: number) {
const request:Array<object> = [ {
insertInlineImage: {
uri: url.toString(),
objectSize: {
height: {
magnitude: height,
unit: 'PT'
},
width: {
magnitude: width,
unit: 'PT'
}
},
location: {
index: 1
}
},
} ];
return request;
}
And then I'm pushing each image request to the full request like.
request.push(imageRequest(image.image.url, 468, 648));
but whatever I put for the width and height is not doing anything. The images are always the original size.
The images are public on an s3 style hosting at Wasabi (similar to amazon s3)
I cannot think of what the problem could be, maybe it's something small that I am overlooking?
help is appreciated, thanks.
The image dimensions are defined by the objectSize property and the Docs documentation states a few rules that define the final size of the image:
If neither width nor height is specified, then a default size of the image is calculated based on its resolution.
If one dimension is specified then the other dimension is calculated to preserve the aspect ratio of the image.
If both width and height are specified, the image is scaled to fit within the provided dimensions while maintaining its aspect ratio.
From these rules it seems that Docs will prioritize the aspect ratio of an image over the exact size, so even if you specify a certain set of dimensions, Docs may resize it to preserve the ratio. As a workaround you can specify only the dimension that you deem more important, (width or height) and Docs will calculate the other one automatically.
In addition, it seems that Docs uses points (PT) rather than pixels (PX) as units to measure dimensions. One point is 1/72 inch while one pixel is 1/96 inch, so if you're used to calculating sizes in pixels as it's most common you'll need to make this conversion as well. A pixel will be 0.75pt while a point will be 1.333...px.
{ id: "Japan", coordinates: [139.6503, 37.6762], image: './icons/Location-icon.png' },
How to add animate.css class, I try to animate icon.png file. is it possible?
To my understanding, ZoomCharts draws the images you give it on an HTML canvas, which means CSS solutions like animate.css won't apply in this case.
I think you'll have to use the ZoomCharts settings to do any styling or animation on the image. See here: https://zoomcharts.com/developers/en/net-chart/api-reference/settings/style/node.html
I'm having trouble in Kivy setting an image size. I want to keep the aspect ratio fixed but I also want to position things precisely over the top of the image.
To do this, I make a RelativeLayout that has the same size and position as the image. However, when I check the size of the layout, it is always slightly larger than the displayed image. Making precise alignment very difficult. The wiki mentions something like this:
By default, the image is centered and fits inside the widget bounding box. If you don’t want that, you can set allow_stretch to True and keep_ratio to False.
They also include code if you want to make the image slightly larger than the containing widget:
<-FullImage>:
canvas:
Color:
rgb: (1, 1, 1)
Rectangle:
texture: self.texture
size: self.width + 20, self.height + 20
pos: self.x - 10, self.y - 10
But nothing about making them exactly the same size!? Surely I should be able to dictate the containing widgets size so the aspect ratio etc. is exactly as required.
I have tried many things but whatever I try, I cannot get the outside edges of the displayed image and a layout to coincide.
Does anyone have any experience with this?
Apologies, I have discovered the problem, the images had a transparent border that I wasn't aware of (the images were passed on to me from elsewhere) I have removed this and it has solved the problem.
I want to resize a textarea in IE in a manner similar to the built in resize in FF and Chrome. So I have applied the jquery ui resizable to the textarea using an se handle. All is good when expanding the textarea. But when reducing the size of the text area somehow the handle gets separated from the corner of the textarea. Like this:-
I am thinking that perhaps some combination of delay and distance could solve this. But the basic demos don't appear to employ these options and their handles don't get separated. So I am beginning to doubt if I am on the right line. Thus far my tinkering with the options has not been successful.
Any thoughts gratefully received.
This is probably NOT the correct answer but it works so I am good for now.
By restricting the expand to the vertical plane only I stopped this behaviour.
$("document").ready(function() {
if ($.browser.msie){
$("textarea").resizable({
handles: "se", maxWidth: 465, minWidth: 465, maxHeight: 350, minHeight: 22
});
}
});
Obviously it is possible to expand in any direction as given in the demos. When a little more time I may review this again.
Can you tell me how to insert image which will be a link to for example page 20? I know how to make with normal text:
text "<link anchor='page20'>Go to page 20</link>", :inline_format=>true
and then on page 20 I have
add_dest('page20', dest_fit(page.dictionary))
but how to do this with image ?
Partly thanks to lightswitch05 for some prodding in the right direction, I've found a way to get the effect I want through this inelegant way:
Insert an image in a bounding_box (the page cursor is at this point at the bottom of the image)
Move the cursor back up to the top of the image
Insert a text link over the image (in my case I just used however many vertical bars '|' were needed to cover the image)
Confirm visually that the clickable link area is about the same as the boundaries of the image
Make the text link transparent, and voilà, it looks like you're clicking the image.
Here's some example code (measurements not exact; there was a lot of tweaking involved):
bounding_box([0, cursor], width: 35) do
image open("http://mysite.com/remote_image.jpg"),
fit: [35, 35],
align: :center
move_up 35
transparent(0) do
formatted_text([{
text: "|||", # placeholder
size: 40,
link: "http://example.com/"
}], align: :center)
end
# stroke_bounds
end
Needless to say, this experience has got me looking a bit more at Wicked PDF in order to do what I think I want to do with PDFs.
I'm sure a better/more elegant solution exists, so I'm not planning on considering this my final answer.
Prawn does not support this functionality. In fact, even if you placed a formatted_text_box over an image and fill it with white space, it still will not work. An anchor has to include text to work. If you don't mind having text over your image, then that might be a solution.
Prawn's own readme states:
One thing Prawn is not, and will never be, is an HTML to PDF generator.
After dealing with many of Prawn's shortcomings, I've switched to using wicked_pdf for my Ruby on Rails PDF generation and have been very happy with it. If you can do it in html & css, it can be done with wicked_pdf.